Add test: starting the same job twice is bad

This commit is contained in:
Lou Knauer 2022-03-21 14:21:44 +01:00
parent 92349708ae
commit 31f31fcece

View File

@ -11,6 +11,7 @@ import (
"path/filepath"
"reflect"
"strconv"
"strings"
"testing"
"github.com/ClusterCockpit/cc-backend/api"
@ -295,4 +296,18 @@ func TestRestApi(t *testing.T) {
t.Fatal("unexpected data fetched from archive")
}
})
t.Run("CheckDoubleStart", func(t *testing.T) {
// Starting a job with the same jobId and cluster should only be allowed if the startTime is far appart!
body := strings.Replace(startJobBody, `"startTime": 123456789`, `"startTime": 123456790`, -1)
req := httptest.NewRequest(http.MethodPost, "/api/jobs/start_job/", bytes.NewBuffer([]byte(body)))
recorder := httptest.NewRecorder()
r.ServeHTTP(recorder, req)
response := recorder.Result()
if response.StatusCode != http.StatusUnprocessableEntity {
t.Fatal(response.Status, recorder.Body.String())
}
})
}