mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
revise file testing
This commit is contained in:
parent
c57b083eed
commit
65f7a9b493
5 changed files with 124 additions and 98 deletions
|
@ -125,14 +125,11 @@ func DummyPopulateDB(test_db *gorm.DB) {
|
||||||
checkErr(test_db.Create(&DashboardA).Error)
|
checkErr(test_db.Create(&DashboardA).Error)
|
||||||
checkErr(test_db.Create(&DashboardB).Error)
|
checkErr(test_db.Create(&DashboardB).Error)
|
||||||
|
|
||||||
file_A := File{Name: "File_A"}
|
// Files
|
||||||
file_B := File{Name: "File_B"}
|
checkErr(test_db.Create(&FileA).Error)
|
||||||
file_C := File{Name: "File_C"}
|
checkErr(test_db.Create(&FileB).Error)
|
||||||
file_D := File{Name: "File_D"}
|
checkErr(test_db.Create(&FileC).Error)
|
||||||
checkErr(test_db.Create(&file_A).Error)
|
checkErr(test_db.Create(&FileD).Error)
|
||||||
checkErr(test_db.Create(&file_B).Error)
|
|
||||||
checkErr(test_db.Create(&file_C).Error)
|
|
||||||
checkErr(test_db.Create(&file_D).Error)
|
|
||||||
|
|
||||||
widg_A := Widget{Name: "Widget_A"}
|
widg_A := Widget{Name: "Widget_A"}
|
||||||
widg_B := Widget{Name: "Widget_B"}
|
widg_B := Widget{Name: "Widget_B"}
|
||||||
|
@ -168,16 +165,16 @@ func DummyPopulateDB(test_db *gorm.DB) {
|
||||||
checkErr(test_db.Model(&SimulationModelA).Association("OutputMapping").Append(&OutSignalB).Error)
|
checkErr(test_db.Model(&SimulationModelA).Association("OutputMapping").Append(&OutSignalB).Error)
|
||||||
|
|
||||||
// SimulationModel HM Files
|
// SimulationModel HM Files
|
||||||
checkErr(test_db.Model(&SimulationModelA).Association("Files").Append(&file_C).Error)
|
checkErr(test_db.Model(&SimulationModelA).Association("Files").Append(&FileC).Error)
|
||||||
checkErr(test_db.Model(&SimulationModelA).Association("Files").Append(&file_D).Error)
|
checkErr(test_db.Model(&SimulationModelA).Association("Files").Append(&FileD).Error)
|
||||||
|
|
||||||
// Simulator HM SimulationModels
|
// Simulator HM SimulationModels
|
||||||
checkErr(test_db.Model(&SimulatorA).Association("SimulationModels").Append(&SimulationModelA).Error)
|
checkErr(test_db.Model(&SimulatorA).Association("SimulationModels").Append(&SimulationModelA).Error)
|
||||||
checkErr(test_db.Model(&SimulatorA).Association("SimulationModels").Append(&SimulationModelB).Error)
|
checkErr(test_db.Model(&SimulatorA).Association("SimulationModels").Append(&SimulationModelB).Error)
|
||||||
|
|
||||||
// Widget HM Files
|
// Widget HM Files
|
||||||
checkErr(test_db.Model(&widg_A).Association("Files").Append(&file_A).Error)
|
checkErr(test_db.Model(&widg_A).Association("Files").Append(&FileA).Error)
|
||||||
checkErr(test_db.Model(&widg_A).Association("Files").Append(&file_B).Error)
|
checkErr(test_db.Model(&widg_A).Association("Files").Append(&FileB).Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erase tables and glose the testdb
|
// Erase tables and glose the testdb
|
||||||
|
|
|
@ -66,8 +66,8 @@ type FileResponse struct {
|
||||||
ID uint `json:"id"`
|
ID uint `json:"id"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Size uint `json:"size"`
|
Size uint `json:"size"`
|
||||||
H uint `json:"imageHeight"`
|
ImageWidth uint `json:"imageHeight"`
|
||||||
W uint `json:"imageWidth"`
|
ImageHeight uint `json:"imageWidth"`
|
||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
WidgetID uint `json:"widgetID"`
|
WidgetID uint `json:"widgetID"`
|
||||||
SimulationModelID uint `json:"simulationModelID"`
|
SimulationModelID uint `json:"simulationModelID"`
|
||||||
|
|
|
@ -254,8 +254,8 @@ func (self *FileSerializerNoAssoc) Response() FileResponse {
|
||||||
//Path: self.Path,
|
//Path: self.Path,
|
||||||
Type: self.Type,
|
Type: self.Type,
|
||||||
Size: self.Size,
|
Size: self.Size,
|
||||||
H: self.ImageHeight,
|
ImageHeight: self.ImageHeight,
|
||||||
W: self.ImageWidth,
|
ImageWidth: self.ImageWidth,
|
||||||
Date: self.Date,
|
Date: self.Date,
|
||||||
WidgetID: self.WidgetID,
|
WidgetID: self.WidgetID,
|
||||||
SimulationModelID: self.SimulationModelID,
|
SimulationModelID: self.SimulationModelID,
|
||||||
|
|
|
@ -20,12 +20,12 @@ var bcryptCost = 10
|
||||||
var pw0, _ = bcrypt.GenerateFromPassword([]byte("xyz789"), bcryptCost)
|
var pw0, _ = bcrypt.GenerateFromPassword([]byte("xyz789"), bcryptCost)
|
||||||
var pwA, _ = bcrypt.GenerateFromPassword([]byte("abc123"), bcryptCost)
|
var pwA, _ = bcrypt.GenerateFromPassword([]byte("abc123"), bcryptCost)
|
||||||
var pwB, _ = bcrypt.GenerateFromPassword([]byte("bcd234"), bcryptCost)
|
var pwB, _ = bcrypt.GenerateFromPassword([]byte("bcd234"), bcryptCost)
|
||||||
var User0 = User{ID: 1, Username: "User_0", Password: string(pw0), Role: "Admin", Mail: "User_0@example.com"}
|
var User0 = User{Username: "User_0", Password: string(pw0), Role: "Admin", Mail: "User_0@example.com"}
|
||||||
var User0_response = UserResponse{Username: User0.Username, Role: User0.Role, ID: User0.ID, Mail: User0.Mail}
|
var User0_response = UserResponse{Username: User0.Username, Role: User0.Role, ID: 1, Mail: User0.Mail}
|
||||||
var UserA = User{ID: 2, Username: "User_A", Password: string(pwA), Role: "User", Mail: "User_A@example.com"}
|
var UserA = User{Username: "User_A", Password: string(pwA), Role: "User", Mail: "User_A@example.com"}
|
||||||
var UserA_response = UserResponse{Username: UserA.Username, Role: UserA.Role, ID: UserA.ID, Mail: UserA.Mail}
|
var UserA_response = UserResponse{Username: UserA.Username, Role: UserA.Role, ID: 2, Mail: UserA.Mail}
|
||||||
var UserB = User{ID: 3, Username: "User_B", Password: string(pwB), Role: "User", Mail: "User_B@example.com"}
|
var UserB = User{Username: "User_B", Password: string(pwB), Role: "User", Mail: "User_B@example.com"}
|
||||||
var UserB_response = UserResponse{Username: UserB.Username, Role: UserB.Role, ID: UserB.ID, Mail: UserB.Mail}
|
var UserB_response = UserResponse{Username: UserB.Username, Role: UserB.Role, ID: 3, Mail: UserB.Mail}
|
||||||
|
|
||||||
// Credentials
|
// Credentials
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@ var propertiesC = json.RawMessage(`{"name" : "TestNameC", "category" : "Category
|
||||||
var propertiesCupdated = json.RawMessage(`{"name" : "TestNameCUpdate", "category" : "CategoryC", "location" : "my desk", "type": "blubb"}`)
|
var propertiesCupdated = json.RawMessage(`{"name" : "TestNameCUpdate", "category" : "CategoryC", "location" : "my desk", "type": "blubb"}`)
|
||||||
|
|
||||||
var SimulatorA = Simulator{
|
var SimulatorA = Simulator{
|
||||||
ID: 1,
|
|
||||||
UUID: "4854af30-325f-44a5-ad59-b67b2597de68",
|
UUID: "4854af30-325f-44a5-ad59-b67b2597de68",
|
||||||
Host: "Host_A",
|
Host: "Host_A",
|
||||||
Modeltype: "ModelTypeA",
|
Modeltype: "ModelTypeA",
|
||||||
|
@ -59,7 +58,7 @@ var SimulatorA = Simulator{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulatorA_response = SimulatorResponse{
|
var SimulatorA_response = SimulatorResponse{
|
||||||
ID: SimulatorA.ID,
|
ID: 1,
|
||||||
UUID: SimulatorA.UUID,
|
UUID: SimulatorA.UUID,
|
||||||
Host: SimulatorA.Host,
|
Host: SimulatorA.Host,
|
||||||
Modeltype: SimulatorA.Modeltype,
|
Modeltype: SimulatorA.Modeltype,
|
||||||
|
@ -71,7 +70,6 @@ var SimulatorA_response = SimulatorResponse{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulatorB = Simulator{
|
var SimulatorB = Simulator{
|
||||||
ID: 2,
|
|
||||||
UUID: "7be0322d-354e-431e-84bd-ae4c9633138b",
|
UUID: "7be0322d-354e-431e-84bd-ae4c9633138b",
|
||||||
Host: "Host_B",
|
Host: "Host_B",
|
||||||
Modeltype: "ModelTypeB",
|
Modeltype: "ModelTypeB",
|
||||||
|
@ -83,7 +81,7 @@ var SimulatorB = Simulator{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulatorB_response = SimulatorResponse{
|
var SimulatorB_response = SimulatorResponse{
|
||||||
ID: SimulatorB.ID,
|
ID: 2,
|
||||||
UUID: SimulatorB.UUID,
|
UUID: SimulatorB.UUID,
|
||||||
Host: SimulatorB.Host,
|
Host: SimulatorB.Host,
|
||||||
Modeltype: SimulatorB.Modeltype,
|
Modeltype: SimulatorB.Modeltype,
|
||||||
|
@ -95,7 +93,6 @@ var SimulatorB_response = SimulatorResponse{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulatorC = Simulator{
|
var SimulatorC = Simulator{
|
||||||
ID: 3,
|
|
||||||
UUID: "6d9776bf-b693-45e8-97b6-4c13d151043f",
|
UUID: "6d9776bf-b693-45e8-97b6-4c13d151043f",
|
||||||
Host: "Host_C",
|
Host: "Host_C",
|
||||||
Modeltype: "ModelTypeC",
|
Modeltype: "ModelTypeC",
|
||||||
|
@ -107,7 +104,7 @@ var SimulatorC = Simulator{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulatorC_response = SimulatorResponse{
|
var SimulatorC_response = SimulatorResponse{
|
||||||
ID: SimulatorC.ID,
|
ID: 3,
|
||||||
UUID: SimulatorC.UUID,
|
UUID: SimulatorC.UUID,
|
||||||
Host: SimulatorC.Host,
|
Host: SimulatorC.Host,
|
||||||
Modeltype: SimulatorC.Modeltype,
|
Modeltype: SimulatorC.Modeltype,
|
||||||
|
@ -119,7 +116,6 @@ var SimulatorC_response = SimulatorResponse{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulatorCUpdated = Simulator{
|
var SimulatorCUpdated = Simulator{
|
||||||
ID: SimulatorC.ID,
|
|
||||||
UUID: SimulatorC.UUID,
|
UUID: SimulatorC.UUID,
|
||||||
Host: "Host_Cupdated",
|
Host: "Host_Cupdated",
|
||||||
Modeltype: "ModelTypeCUpdated",
|
Modeltype: "ModelTypeCUpdated",
|
||||||
|
@ -131,7 +127,7 @@ var SimulatorCUpdated = Simulator{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulatorCUpdated_response = SimulatorResponse{
|
var SimulatorCUpdated_response = SimulatorResponse{
|
||||||
ID: SimulatorCUpdated.ID,
|
ID: 3,
|
||||||
UUID: SimulatorCUpdated.UUID,
|
UUID: SimulatorCUpdated.UUID,
|
||||||
Host: SimulatorCUpdated.Host,
|
Host: SimulatorCUpdated.Host,
|
||||||
Modeltype: SimulatorCUpdated.Modeltype,
|
Modeltype: SimulatorCUpdated.Modeltype,
|
||||||
|
@ -148,19 +144,18 @@ var startParametersA = json.RawMessage(`{"parameter1" : "testValue1A", "paramete
|
||||||
var startParametersB = json.RawMessage(`{"parameter1" : "testValue1B", "parameter2" : "testValue2B", "parameter3" : 43}`)
|
var startParametersB = json.RawMessage(`{"parameter1" : "testValue1B", "parameter2" : "testValue2B", "parameter3" : 43}`)
|
||||||
var startParametersC = json.RawMessage(`{"parameter1" : "testValue1C", "parameter2" : "testValue2C", "parameter3" : 44}`)
|
var startParametersC = json.RawMessage(`{"parameter1" : "testValue1C", "parameter2" : "testValue2C", "parameter3" : 44}`)
|
||||||
|
|
||||||
var ScenarioA = Scenario{ID: 1, Name: "Scenario_A", Running: true, StartParameters: postgres.Jsonb{startParametersA}}
|
var ScenarioA = Scenario{Name: "Scenario_A", Running: true, StartParameters: postgres.Jsonb{startParametersA}}
|
||||||
var ScenarioA_response = ScenarioResponse{ID: ScenarioA.ID, Name: ScenarioA.Name, Running: ScenarioA.Running, StartParameters: ScenarioA.StartParameters}
|
var ScenarioA_response = ScenarioResponse{ID: 1, Name: ScenarioA.Name, Running: ScenarioA.Running, StartParameters: ScenarioA.StartParameters}
|
||||||
var ScenarioB = Scenario{ID: 2, Name: "Scenario_B", Running: false, StartParameters: postgres.Jsonb{startParametersB}}
|
var ScenarioB = Scenario{Name: "Scenario_B", Running: false, StartParameters: postgres.Jsonb{startParametersB}}
|
||||||
var ScenarioB_response = ScenarioResponse{ID: ScenarioB.ID, Name: ScenarioB.Name, Running: ScenarioB.Running, StartParameters: ScenarioB.StartParameters}
|
var ScenarioB_response = ScenarioResponse{ID: 2, Name: ScenarioB.Name, Running: ScenarioB.Running, StartParameters: ScenarioB.StartParameters}
|
||||||
var ScenarioC = Scenario{ID: 3, Name: "Scenario_C", Running: false, StartParameters: postgres.Jsonb{startParametersC}}
|
var ScenarioC = Scenario{Name: "Scenario_C", Running: false, StartParameters: postgres.Jsonb{startParametersC}}
|
||||||
var ScenarioC_response = ScenarioResponse{ID: ScenarioC.ID, Name: ScenarioC.Name, Running: ScenarioC.Running, StartParameters: ScenarioC.StartParameters}
|
var ScenarioC_response = ScenarioResponse{ID: 3, Name: ScenarioC.Name, Running: ScenarioC.Running, StartParameters: ScenarioC.StartParameters}
|
||||||
var ScenarioCUpdated = Scenario{ID: ScenarioC.ID, Name: "Scenario_Cupdated", Running: true, StartParameters: postgres.Jsonb{startParametersC}}
|
var ScenarioCUpdated = Scenario{Name: "Scenario_Cupdated", Running: true, StartParameters: postgres.Jsonb{startParametersC}}
|
||||||
var ScenarioCUpdated_response = ScenarioResponse{ID: ScenarioCUpdated.ID, Name: ScenarioCUpdated.Name, Running: ScenarioCUpdated.Running, StartParameters: ScenarioCUpdated.StartParameters}
|
var ScenarioCUpdated_response = ScenarioResponse{ID: 3, Name: ScenarioCUpdated.Name, Running: ScenarioCUpdated.Running, StartParameters: ScenarioCUpdated.StartParameters}
|
||||||
|
|
||||||
// Simulation Models
|
// Simulation Models
|
||||||
|
|
||||||
var SimulationModelA = SimulationModel{
|
var SimulationModelA = SimulationModel{
|
||||||
ID: 1,
|
|
||||||
Name: "SimulationModel_A",
|
Name: "SimulationModel_A",
|
||||||
OutputLength: 1,
|
OutputLength: 1,
|
||||||
InputLength: 1,
|
InputLength: 1,
|
||||||
|
@ -170,7 +165,7 @@ var SimulationModelA = SimulationModel{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulationModelA_response = SimulationModelResponse{
|
var SimulationModelA_response = SimulationModelResponse{
|
||||||
ID: SimulationModelA.ID,
|
ID: 1,
|
||||||
Name: SimulationModelA.Name,
|
Name: SimulationModelA.Name,
|
||||||
InputLength: SimulationModelA.InputLength,
|
InputLength: SimulationModelA.InputLength,
|
||||||
OutputLength: SimulationModelA.OutputLength,
|
OutputLength: SimulationModelA.OutputLength,
|
||||||
|
@ -180,7 +175,6 @@ var SimulationModelA_response = SimulationModelResponse{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulationModelB = SimulationModel{
|
var SimulationModelB = SimulationModel{
|
||||||
ID: 2,
|
|
||||||
Name: "SimulationModel_B",
|
Name: "SimulationModel_B",
|
||||||
OutputLength: 1,
|
OutputLength: 1,
|
||||||
InputLength: 1,
|
InputLength: 1,
|
||||||
|
@ -190,7 +184,7 @@ var SimulationModelB = SimulationModel{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulationModelB_response = SimulationModelResponse{
|
var SimulationModelB_response = SimulationModelResponse{
|
||||||
ID: SimulationModelB.ID,
|
ID: 2,
|
||||||
Name: SimulationModelB.Name,
|
Name: SimulationModelB.Name,
|
||||||
InputLength: SimulationModelB.InputLength,
|
InputLength: SimulationModelB.InputLength,
|
||||||
OutputLength: SimulationModelB.OutputLength,
|
OutputLength: SimulationModelB.OutputLength,
|
||||||
|
@ -200,7 +194,6 @@ var SimulationModelB_response = SimulationModelResponse{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulationModelC = SimulationModel{
|
var SimulationModelC = SimulationModel{
|
||||||
ID: 3,
|
|
||||||
Name: "SimulationModel_C",
|
Name: "SimulationModel_C",
|
||||||
OutputLength: 1,
|
OutputLength: 1,
|
||||||
InputLength: 1,
|
InputLength: 1,
|
||||||
|
@ -210,7 +203,7 @@ var SimulationModelC = SimulationModel{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulationModelC_response = SimulationModelResponse{
|
var SimulationModelC_response = SimulationModelResponse{
|
||||||
ID: SimulationModelC.ID,
|
ID: 3,
|
||||||
Name: SimulationModelC.Name,
|
Name: SimulationModelC.Name,
|
||||||
InputLength: SimulationModelC.InputLength,
|
InputLength: SimulationModelC.InputLength,
|
||||||
OutputLength: SimulationModelC.OutputLength,
|
OutputLength: SimulationModelC.OutputLength,
|
||||||
|
@ -220,7 +213,6 @@ var SimulationModelC_response = SimulationModelResponse{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulationModelCUpdated = SimulationModel{
|
var SimulationModelCUpdated = SimulationModel{
|
||||||
ID: SimulationModelC.ID,
|
|
||||||
Name: "SimulationModel_CUpdated",
|
Name: "SimulationModel_CUpdated",
|
||||||
OutputLength: SimulationModelC.OutputLength,
|
OutputLength: SimulationModelC.OutputLength,
|
||||||
InputLength: SimulationModelC.InputLength,
|
InputLength: SimulationModelC.InputLength,
|
||||||
|
@ -232,7 +224,7 @@ var SimulationModelCUpdated = SimulationModel{
|
||||||
}
|
}
|
||||||
|
|
||||||
var SimulationModelCUpdated_response = SimulationModelResponse{
|
var SimulationModelCUpdated_response = SimulationModelResponse{
|
||||||
ID: SimulationModelCUpdated.ID,
|
ID: 3,
|
||||||
Name: SimulationModelCUpdated.Name,
|
Name: SimulationModelCUpdated.Name,
|
||||||
InputLength: SimulationModelCUpdated.InputLength,
|
InputLength: SimulationModelCUpdated.InputLength,
|
||||||
OutputLength: SimulationModelCUpdated.OutputLength,
|
OutputLength: SimulationModelCUpdated.OutputLength,
|
||||||
|
@ -341,11 +333,80 @@ var InSignalCUpdated_response = SignalResponse{
|
||||||
|
|
||||||
// Dashboards
|
// Dashboards
|
||||||
|
|
||||||
var DashboardA = Dashboard{ID: 1, Name: "Dashboard_A", Grid: 15, ScenarioID: 1}
|
var DashboardA = Dashboard{Name: "Dashboard_A", Grid: 15, ScenarioID: 1}
|
||||||
var DashboardA_response = DashboardResponse{ID: DashboardA.ID, Name: DashboardA.Name, Grid: DashboardA.Grid, ScenarioID: DashboardA.ScenarioID}
|
var DashboardA_response = DashboardResponse{ID: 1, Name: DashboardA.Name, Grid: DashboardA.Grid, ScenarioID: DashboardA.ScenarioID}
|
||||||
var DashboardB = Dashboard{ID: 2, Name: "Dashboard_B", Grid: 10, ScenarioID: 1}
|
var DashboardB = Dashboard{Name: "Dashboard_B", Grid: 10, ScenarioID: 1}
|
||||||
var DashboardB_response = DashboardResponse{ID: DashboardB.ID, Name: DashboardB.Name, Grid: DashboardB.Grid, ScenarioID: DashboardB.ScenarioID}
|
var DashboardB_response = DashboardResponse{ID: 2, Name: DashboardB.Name, Grid: DashboardB.Grid, ScenarioID: DashboardB.ScenarioID}
|
||||||
var DashboardC = Dashboard{ID: 3, Name: "Dashboard_C", Grid: 25, ScenarioID: 1}
|
var DashboardC = Dashboard{Name: "Dashboard_C", Grid: 25, ScenarioID: 1}
|
||||||
var DashboardC_response = DashboardResponse{ID: DashboardC.ID, Name: DashboardC.Name, Grid: DashboardC.Grid, ScenarioID: DashboardC.ScenarioID}
|
var DashboardC_response = DashboardResponse{ID: 3, Name: DashboardC.Name, Grid: DashboardC.Grid, ScenarioID: DashboardC.ScenarioID}
|
||||||
var DashboardCUpdated = Dashboard{ID: DashboardC.ID, Name: "Dashboard_Cupdated", Grid: 24, ScenarioID: DashboardC.ScenarioID}
|
var DashboardCUpdated = Dashboard{Name: "Dashboard_Cupdated", Grid: 24, ScenarioID: DashboardC.ScenarioID}
|
||||||
var DashboardCUpdated_response = DashboardResponse{ID: DashboardCUpdated.ID, Name: DashboardCUpdated.Name, Grid: DashboardCUpdated.Grid, ScenarioID: DashboardCUpdated.ScenarioID}
|
var DashboardCUpdated_response = DashboardResponse{ID: 3, Name: DashboardCUpdated.Name, Grid: DashboardCUpdated.Grid, ScenarioID: DashboardCUpdated.ScenarioID}
|
||||||
|
|
||||||
|
// Files
|
||||||
|
|
||||||
|
var FileA = File{
|
||||||
|
Name: "File_A",
|
||||||
|
Type: "text/plain",
|
||||||
|
Size: 42,
|
||||||
|
ImageHeight: 333,
|
||||||
|
ImageWidth: 111,
|
||||||
|
Date: time.Now().String(),
|
||||||
|
WidgetID: 1,
|
||||||
|
SimulationModelID: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
var FileA_response = FileResponse{
|
||||||
|
ID: 1,
|
||||||
|
Name: FileA.Name,
|
||||||
|
Type: FileA.Type,
|
||||||
|
Size: FileA.Size,
|
||||||
|
ImageWidth: FileA.ImageWidth,
|
||||||
|
ImageHeight: FileA.ImageHeight,
|
||||||
|
Date: FileA.Date,
|
||||||
|
WidgetID: FileA.WidgetID,
|
||||||
|
SimulationModelID: FileA.SimulationModelID,
|
||||||
|
}
|
||||||
|
|
||||||
|
var FileB = File{
|
||||||
|
Name: "File_B",
|
||||||
|
Type: "text/plain",
|
||||||
|
Size: 1234,
|
||||||
|
ImageHeight: 55,
|
||||||
|
ImageWidth: 22,
|
||||||
|
Date: time.Now().String(),
|
||||||
|
WidgetID: 1,
|
||||||
|
SimulationModelID: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
var FileB_response = FileResponse{
|
||||||
|
ID: 2,
|
||||||
|
Name: FileB.Name,
|
||||||
|
Type: FileB.Type,
|
||||||
|
Size: FileB.Size,
|
||||||
|
ImageWidth: FileB.ImageWidth,
|
||||||
|
ImageHeight: FileB.ImageHeight,
|
||||||
|
Date: FileB.Date,
|
||||||
|
WidgetID: FileB.WidgetID,
|
||||||
|
SimulationModelID: FileB.SimulationModelID,
|
||||||
|
}
|
||||||
|
|
||||||
|
var FileC = File{
|
||||||
|
Name: "File_C",
|
||||||
|
Type: "text/plain",
|
||||||
|
Size: 32,
|
||||||
|
ImageHeight: 10,
|
||||||
|
ImageWidth: 10,
|
||||||
|
Date: time.Now().String(),
|
||||||
|
WidgetID: 0,
|
||||||
|
SimulationModelID: 1,
|
||||||
|
}
|
||||||
|
var FileD = File{
|
||||||
|
Name: "File_D",
|
||||||
|
Type: "text/plain",
|
||||||
|
Size: 5000,
|
||||||
|
ImageHeight: 400,
|
||||||
|
ImageWidth: 800,
|
||||||
|
Date: time.Now().String(),
|
||||||
|
WidgetID: 0,
|
||||||
|
SimulationModelID: 1,
|
||||||
|
}
|
||||||
|
|
|
@ -17,50 +17,18 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var token string
|
// Test /files endpoints
|
||||||
var filecontent = "This is my testfile"
|
|
||||||
var filecontent_update = "This is my updated testfile with a dot at the end."
|
|
||||||
var filename = "testfile.txt"
|
|
||||||
var filename_update = "testfileupdate.txt"
|
|
||||||
|
|
||||||
type credentials struct {
|
|
||||||
Username string `json:"username"`
|
|
||||||
Password string `json:"password"`
|
|
||||||
}
|
|
||||||
|
|
||||||
var cred = credentials{
|
|
||||||
Username: "User_A",
|
|
||||||
Password: "abc123",
|
|
||||||
}
|
|
||||||
|
|
||||||
var msgOK = common.ResponseMsg{
|
|
||||||
Message: "OK.",
|
|
||||||
}
|
|
||||||
|
|
||||||
var FileA = common.FileResponse{
|
|
||||||
Name: "File_A",
|
|
||||||
ID: 1,
|
|
||||||
WidgetID: 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
var FileB = common.FileResponse{
|
|
||||||
Name: "File_B",
|
|
||||||
ID: 2,
|
|
||||||
WidgetID: 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
var myFiles = []common.FileResponse{
|
|
||||||
FileA,
|
|
||||||
FileB,
|
|
||||||
}
|
|
||||||
|
|
||||||
var msgFiles = common.ResponseMsgFiles{
|
|
||||||
Files: myFiles,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test /models endpoints
|
|
||||||
func TestSignalEndpoints(t *testing.T) {
|
func TestSignalEndpoints(t *testing.T) {
|
||||||
|
|
||||||
|
var token string
|
||||||
|
var filecontent = "This is my testfile"
|
||||||
|
var filecontent_update = "This is my updated testfile with a dot at the end."
|
||||||
|
var filename = "testfile.txt"
|
||||||
|
var filename_update = "testfileupdate.txt"
|
||||||
|
|
||||||
|
var myFiles = []common.FileResponse{common.FileA_response, common.FileB_response}
|
||||||
|
var msgFiles = common.ResponseMsgFiles{Files: myFiles}
|
||||||
|
|
||||||
db := common.DummyInitDB()
|
db := common.DummyInitDB()
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
common.DummyPopulateDB(db)
|
common.DummyPopulateDB(db)
|
||||||
|
@ -88,12 +56,12 @@ func TestSignalEndpoints(t *testing.T) {
|
||||||
|
|
||||||
RegisterFileEndpoints(api.Group("/files"))
|
RegisterFileEndpoints(api.Group("/files"))
|
||||||
|
|
||||||
credjson, err := json.Marshal(cred)
|
credjson, err := json.Marshal(common.CredUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
msgOKjson, err := json.Marshal(msgOK)
|
msgOKjson, err := json.Marshal(common.MsgOK)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue