1 module source.konnexengine.app.data; 2 3 import konnexengine.modules.blueprint; 4 import vibe.data.json: Json; 5 6 /// AppDataInterface `interface` 7 interface AppDataInterface 8 { 9 10 } 11 12 /// AppData `struct` 13 struct AppData { 14 string name = ""; 15 string namespace = ""; 16 string accessToken = ""; 17 string refreshToken = ""; 18 string page = ""; 19 string username = ""; 20 Json videos = Json(""); 21 Json currentVideo; 22 } 23 /// 24 unittest { 25 import fastjwt.jwt; 26 import vibe.data.json: Json; 27 28 auto data = AppData 29 ( 30 "Test App", 31 "Test Module", 32 "token", 33 "refreshToken", 34 "crowdfunding", 35 "user1", 36 Json(""), 37 Json() 38 ); 39 40 assert(is(typeof(data) == AppData)); 41 assert(is(typeof(data.name) == string)); 42 assert(is(typeof(data.namespace) == string)); 43 assert(is(typeof(data.accessToken) == string)); 44 assert(is(typeof(data.refreshToken) == string)); 45 assert(is(typeof(data.page) == string)); 46 assert(is(typeof(data.username) == string)); 47 assert(is(typeof(data.videos) == Json)); 48 assert(is(typeof(data.currentVideo) == Json)); 49 assert(data.name == "Test App"); 50 assert(data.namespace == "Test Module"); 51 assert(data.accessToken == "token"); 52 assert(data.refreshToken == "refreshToken"); 53 assert(data.page == "crowdfunding"); 54 assert(data.username == "user1"); 55 assert(data.videos == Json("")); 56 // assert(data.currentVideo == "vky56f6uykty"); 57 58 } 59 60 /// AuthState `struct` 61 struct AuthState { 62 /// signuo - `bool` 63 bool signup = false; 64 /// passwordRequired - `bool` 65 bool passwordRequired = false; 66 /// login - `bool` 67 bool login = false; 68 /// success - `bool` 69 bool success = false; 70 /// valid - `bool` 71 bool valid = false; 72 } 73 /// 74 unittest { 75 auto state = AuthState(); 76 assert(is(typeof(state) == AuthState)); 77 assert(is(typeof(state.signup) == bool)); 78 assert(is(typeof(state.passwordRequired) == bool)); 79 assert(is(typeof(state.success) == bool)); 80 assert(is(typeof(state.login) == bool)); 81 assert(is(typeof(state.valid) == bool)); 82 assert(state.signup == false); 83 assert(state.passwordRequired == false); 84 assert(state.success == false); 85 assert(state.login == false); 86 assert(state.valid == false); 87 } 88 89 90