Commit 44c1a0f2 authored by Sonja Happ's avatar Sonja Happ
Browse files

WIP: result test independent of test data

parent ca0ccf82
......@@ -65,6 +65,10 @@ type ResponseResult struct {
Result database.Result `json:"result"`
}
var newResult = ResultRequest{
Description: "This is a test result.",
}
func addScenario() (scenarioID uint) {
// authenticate as admin
......@@ -77,9 +81,9 @@ func addScenario() (scenarioID uint) {
// POST $newScenario
newScenario := ScenarioRequest{
Name: helper.ScenarioA.Name,
Running: helper.ScenarioA.Running,
StartParameters: helper.ScenarioA.StartParameters,
Name: "Scenario1",
Running: true,
StartParameters: postgres.Jsonb{RawMessage: json.RawMessage(`{"parameter1" : "testValue1A", "parameter2" : "testValue2A", "parameter3" : 42}`)},
}
_, resp, _ := helper.TestEndpoint(router, token,
"/api/scenarios", "POST", helper.KeyModels{"scenario": newScenario})
......@@ -139,12 +143,8 @@ func TestGetAllResultsOfScenario(t *testing.T) {
configSnapshot1 := json.RawMessage(`{"configs": [ {"Name" : "conf1", "scenarioID" : 1}, {"Name" : "conf2", "scenarioID" : 1}]}`)
confSnapshots := postgres.Jsonb{configSnapshot1}
newResult := ResultRequest{
Description: "This is a test result.",
ScenarioID: scenarioID,
ConfigSnapshots: confSnapshots,
}
newResult.ScenarioID = scenarioID
newResult.ConfigSnapshots = confSnapshots
code, resp, err := helper.TestEndpoint(router, token,
base_api_results, "POST", helper.KeyModels{"result": newResult})
assert.NoError(t, err)
......@@ -182,13 +182,8 @@ func TestAddGetUpdateDeleteResult(t *testing.T) {
scenarioID := addScenario()
configSnapshot1 := json.RawMessage(`{"configs": [ {"Name" : "conf1", "scenarioID" : 1}, {"Name" : "conf2", "scenarioID" : 1}]}`)
confSnapshots := postgres.Jsonb{configSnapshot1}
newResult := ResultRequest{
Description: "This is a test result.",
ScenarioID: scenarioID,
ConfigSnapshots: confSnapshots,
}
newResult.ScenarioID = scenarioID
newResult.ConfigSnapshots = confSnapshots
// authenticate as normal userB who has no access to new scenario
token, err := helper.AuthenticateForTest(router,
base_api_auth, "POST", helper.UserBCredentials)
......@@ -368,12 +363,8 @@ func TestAddDeleteResultFile(t *testing.T) {
configSnapshot1 := json.RawMessage(`{"configs": [ {"Name" : "conf1", "scenarioID" : 1}, {"Name" : "conf2", "scenarioID" : 1}]}`)
confSnapshots := postgres.Jsonb{configSnapshot1}
newResult := ResultRequest{
Description: "This is a test result.",
ScenarioID: scenarioID,
ConfigSnapshots: confSnapshots,
}
newResult.ScenarioID = scenarioID
newResult.ConfigSnapshots = confSnapshots
// authenticate as normal user
token, err := helper.AuthenticateForTest(router,
base_api_auth, "POST", helper.UserACredentials)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment