github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/engine/trancode/trancode_test.go (about) 1 package trancode 2 3 import ( 4 "context" 5 "database/sql" 6 "reflect" 7 "testing" 8 9 "github.com/mdaxf/iac/documents" 10 "github.com/mdaxf/iac/engine/types" 11 "github.com/mdaxf/iac-signalr/signalr" 12 ) 13 14 func TestExecutebyExternal(t *testing.T) { 15 type args struct { 16 trancode string 17 data map[string]interface{} 18 DBTx *sql.Tx 19 DBCon *documents.DocDB 20 sc signalr.Client 21 } 22 tests := []struct { 23 name string 24 args args 25 want map[string]interface{} 26 wantErr bool 27 }{ 28 // TODO: Add test cases. 29 } 30 for _, tt := range tests { 31 t.Run(tt.name, func(t *testing.T) { 32 got, err := ExecutebyExternal(tt.args.trancode, tt.args.data, tt.args.DBTx, tt.args.DBCon, tt.args.sc) 33 if (err != nil) != tt.wantErr { 34 t.Errorf("ExecutebyExternal() error = %v, wantErr %v", err, tt.wantErr) 35 return 36 } 37 if !reflect.DeepEqual(got, tt.want) { 38 t.Errorf("ExecutebyExternal() = %v, want %v", got, tt.want) 39 } 40 }) 41 } 42 } 43 44 func TestTranFlow_Execute(t *testing.T) { 45 tests := []struct { 46 name string 47 tr *TranFlow 48 want map[string]interface{} 49 wantErr bool 50 }{ 51 // TODO: Add test cases. 52 } 53 for _, tt := range tests { 54 t.Run(tt.name, func(t *testing.T) { 55 got, err := tt.tr.Execute() 56 if (err != nil) != tt.wantErr { 57 t.Errorf("TranFlow.Execute() error = %v, wantErr %v", err, tt.wantErr) 58 return 59 } 60 if !reflect.DeepEqual(got, tt.want) { 61 t.Errorf("TranFlow.Execute() = %v, want %v", got, tt.want) 62 } 63 }) 64 } 65 } 66 67 func TestTranFlow_getFGbyName(t *testing.T) { 68 type args struct { 69 name string 70 } 71 tests := []struct { 72 name string 73 tr *TranFlow 74 args args 75 want types.FuncGroup 76 want1 int 77 }{ 78 // TODO: Add test cases. 79 } 80 for _, tt := range tests { 81 t.Run(tt.name, func(t *testing.T) { 82 got, got1 := tt.tr.getFGbyName(tt.args.name) 83 if !reflect.DeepEqual(got, tt.want) { 84 t.Errorf("TranFlow.getFGbyName() got = %v, want %v", got, tt.want) 85 } 86 if got1 != tt.want1 { 87 t.Errorf("TranFlow.getFGbyName() got1 = %v, want %v", got1, tt.want1) 88 } 89 }) 90 } 91 } 92 93 func TestGetTransCode(t *testing.T) { 94 type args struct { 95 name string 96 } 97 tests := []struct { 98 name string 99 args args 100 want types.TranCode 101 wantErr bool 102 }{ 103 // TODO: Add test cases. 104 } 105 for _, tt := range tests { 106 t.Run(tt.name, func(t *testing.T) { 107 got, err := GetTransCode(tt.args.name) 108 if (err != nil) != tt.wantErr { 109 t.Errorf("GetTransCode() error = %v, wantErr %v", err, tt.wantErr) 110 return 111 } 112 if !reflect.DeepEqual(got, tt.want) { 113 t.Errorf("GetTransCode() = %v, want %v", got, tt.want) 114 } 115 }) 116 } 117 } 118 119 func TestBytetoobj(t *testing.T) { 120 type args struct { 121 config []byte 122 } 123 tests := []struct { 124 name string 125 args args 126 want types.TranCode 127 wantErr bool 128 }{ 129 { 130 name: "test", 131 args: args{ 132 config: []byte(`{ 133 "code": "test", 134 "functiongroups": [ 135 { 136 "name": "test", 137 "functions": [ 138 { 139 "name": "test", 140 "function": "test", 141 "inputs": [ 142 { 143 "name": "test", 144 "type": "test", 145 "required": true, 146 "validation": "test", 147 "validationmessage": "test", 148 "validationtype": "test", 149 "validationvalue": "test", 150 "validationvalue2": "test", 151 "validationvalue3": "test", 152 }] 153 }] 154 }] 155 }`), 156 }, 157 want: types.TranCode{}, 158 wantErr: true, // TODO: Add test cases 159 }, 160 } 161 for _, tt := range tests { 162 t.Run(tt.name, func(t *testing.T) { 163 got, err := Bytetoobj(tt.args.config) 164 if (err != nil) != tt.wantErr { 165 t.Errorf("Bytetoobj() error = %v, wantErr %v", err, tt.wantErr) 166 return 167 } 168 if !reflect.DeepEqual(got, tt.want) { 169 t.Errorf("Bytetoobj() = %v, want %v", got, tt.want) 170 } 171 }) 172 } 173 } 174 175 func TestConfigtoobj(t *testing.T) { 176 type args struct { 177 config string 178 } 179 tests := []struct { 180 name string 181 args args 182 want types.TranCode 183 wantErr bool 184 }{ 185 // TODO: Add test cases. 186 } 187 for _, tt := range tests { 188 t.Run(tt.name, func(t *testing.T) { 189 got, err := Configtoobj(tt.args.config) 190 if (err != nil) != tt.wantErr { 191 t.Errorf("Configtoobj() error = %v, wantErr %v", err, tt.wantErr) 192 return 193 } 194 if !reflect.DeepEqual(got, tt.want) { 195 t.Errorf("Configtoobj() = %v, want %v", got, tt.want) 196 } 197 }) 198 } 199 } 200 201 func TestTranFlowstr_Execute(t *testing.T) { 202 type args struct { 203 tcode string 204 inputs map[string]interface{} 205 ctx context.Context 206 ctxcancel context.CancelFunc 207 dbTx []*sql.Tx 208 sc signalr.Client 209 doc *documents.DocDB 210 } 211 tests := []struct { 212 name string 213 tr *TranFlowstr 214 args args 215 want map[string]interface{} 216 wantErr bool 217 }{ 218 // TODO: Add test cases. 219 } 220 for _, tt := range tests { 221 t.Run(tt.name, func(t *testing.T) { 222 got, err := tt.tr.Execute(tt.args.tcode, tt.args.inputs, tt.args.sc, tt.args.doc, tt.args.ctx, tt.args.ctxcancel, tt.args.dbTx...) 223 if (err != nil) != tt.wantErr { 224 t.Errorf("TranFlowstr.Execute() error = %v, wantErr %v", err, tt.wantErr) 225 return 226 } 227 if !reflect.DeepEqual(got, tt.want) { 228 t.Errorf("TranFlowstr.Execute() = %v, want %v", got, tt.want) 229 } 230 }) 231 } 232 } 233 234 func TestGetTranCodeData(t *testing.T) { 235 type args struct { 236 Code string 237 } 238 tests := []struct { 239 name string 240 args args 241 want types.TranCode 242 wantErr bool 243 }{ 244 // TODO: Add test cases. 245 } 246 for _, tt := range tests { 247 t.Run(tt.name, func(t *testing.T) { 248 got, err := GetTranCodeDatabyCode(tt.args.Code) 249 if (err != nil) != tt.wantErr { 250 t.Errorf("GetTranCodeData() error = %v, wantErr %v", err, tt.wantErr) 251 return 252 } 253 if !reflect.DeepEqual(got, tt.want) { 254 t.Errorf("GetTranCodeData() = %v, want %v", got, tt.want) 255 } 256 }) 257 } 258 } 259 260 func Test_getTranCodeData(t *testing.T) { 261 type args struct { 262 Code string 263 DBConn *documents.DocDB 264 } 265 tests := []struct { 266 name string 267 args args 268 want types.TranCode 269 wantErr bool 270 }{ 271 // TODO: Add test cases. 272 } 273 for _, tt := range tests { 274 t.Run(tt.name, func(t *testing.T) { 275 got, err := getTranCodeData(tt.args.Code, tt.args.DBConn) 276 if (err != nil) != tt.wantErr { 277 t.Errorf("getTranCodeData() error = %v, wantErr %v", err, tt.wantErr) 278 return 279 } 280 if !reflect.DeepEqual(got, tt.want) { 281 t.Errorf("getTranCodeData() = %v, want %v", got, tt.want) 282 } 283 }) 284 } 285 }