diff --git a/cmd/engines_test.go b/cmd/engines_test.go index eb5c7be..ef626c4 100644 --- a/cmd/engines_test.go +++ b/cmd/engines_test.go @@ -309,6 +309,7 @@ func TestEngines(t *testing.T) { statusCode: http.StatusOK, body: responseV3, args: []string{"engines"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "NAME[\\s]*HOST[\\s]*BUILD[\\s]*PLATFORM[\\s]*TYPE[\\s]*CURRENT JOB ID[\\s]*REGISTRATION PROPERTIES[\\s]*QUEUES[\\s]*[\\s]*387f74cd4e1f[\\s]*387f74cd4e1f[\\s]*23166[\\s]*linux-x64[\\s]*STANDARD[\\s]*-1[\\s]*\\[Standard 387f74cd4e1f 387f74cd4e1f 23166 linux-x64\\][\\s]*\\[Default\\]", }, { @@ -316,6 +317,7 @@ func TestEngines(t *testing.T) { statusCode: http.StatusOK, body: responseV3, args: []string{"engines", "--no-headers"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "[\\s]*387f74cd4e1f[\\s]*387f74cd4e1f[\\s]*23166[\\s]*linux-x64[\\s]*STANDARD[\\s]*-1[\\s]*\\[Standard 387f74cd4e1f 387f74cd4e1f 23166 linux-x64\\][\\s]*\\[Default\\]", }, { @@ -323,6 +325,7 @@ func TestEngines(t *testing.T) { statusCode: http.StatusOK, args: []string{"engines", "--json"}, body: responseV3, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputJson: responseV3, }, { @@ -330,6 +333,7 @@ func TestEngines(t *testing.T) { statusCode: http.StatusOK, args: []string{"engines", "--output=json"}, body: responseV3, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputJson: responseV3, }, { @@ -337,6 +341,7 @@ func TestEngines(t *testing.T) { statusCode: http.StatusOK, body: responseV3FourEngines, args: []string{"engines", "--count"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "4", }, { @@ -344,6 +349,7 @@ func TestEngines(t *testing.T) { statusCode: http.StatusOK, body: responseV3FourEngines, args: []string{"engines", "--output=custom-columns=ENGINEMANAGER:.engineManagerNodeName,TRANSACTIONPORT:.transactionPort,CURRENTJOB:.currentJobID"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "[\\s]*ENGINEMANAGER[\\s]*TRANSACTIONPORT[\\s]*CURRENTJOB[\\s]*fmeflowcore[\\s]*40935[\\s]*-1[\\s]*fmeflowcore[\\s]*36883[\\s]*-1[\\s]*fmeflowcore[\\s]*44089[\\s]*-1[\\s]*fmeflowcore[\\s]*44795[\\s]*-1", }, diff --git a/cmd/jobs_v3_test.go b/cmd/jobs_v3_test.go index 522dbea..1709973 100644 --- a/cmd/jobs_v3_test.go +++ b/cmd/jobs_v3_test.go @@ -463,24 +463,28 @@ func TestJobs(t *testing.T) { name: "unknown flag", statusCode: http.StatusOK, args: []string{"jobs", "--badflag"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantErrOutputRegex: "unknown flag: --badflag", }, { - name: "500 bad status code", - statusCode: http.StatusInternalServerError, - wantErrText: "500 Internal Server Error", - args: []string{"jobs"}, + name: "500 bad status code", + statusCode: http.StatusInternalServerError, + wantErrText: "500 Internal Server Error", + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) + args: []string{"jobs"}, }, { - name: "404 bad status code", - statusCode: http.StatusNotFound, - wantErrText: "404 Not Found", - args: []string{"jobs"}, + name: "404 bad status code", + statusCode: http.StatusNotFound, + wantErrText: "404 Not Found", + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) + args: []string{"jobs"}, }, { name: "get jobs table output", statusCode: http.StatusOK, args: []string{"jobs"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*4[\\s]*10f259e906e5[\\s]*running.fmw[\\s]*PULLED[\\s]*1[\\s]*austinApartments.fmw[\\s]*QUEUED[\\s]*3[\\s]*387f74cd4e1f[\\s]*austinApartments.fmw[\\s]*SUCCESS[\\s]*2[\\s]*10f259e906e5[\\s]*none2none.fmw[\\s]*FME_FAILURE[\\s]*$", httpServer: httptest.NewServer(http.HandlerFunc(customHttpServerHandler)), }, @@ -488,6 +492,7 @@ func TestJobs(t *testing.T) { name: "get jobs all table output", statusCode: http.StatusOK, args: []string{"jobs", "--all"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*4[\\s]*10f259e906e5[\\s]*running.fmw[\\s]*PULLED[\\s]*1[\\s]*austinApartments.fmw[\\s]*QUEUED[\\s]*3[\\s]*387f74cd4e1f[\\s]*austinApartments.fmw[\\s]*SUCCESS[\\s]*2[\\s]*10f259e906e5[\\s]*none2none.fmw[\\s]*FME_FAILURE[\\s]*$", httpServer: httptest.NewServer(http.HandlerFunc(customHttpServerHandler)), }, @@ -496,6 +501,7 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, body: responseV3Running, args: []string{"jobs", "--running"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*4[\\s]*10f259e906e5[\\s]*running.fmw[\\s]*PULLED[\\s]*$", }, { @@ -503,6 +509,7 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, body: responseV3Active, args: []string{"jobs", "--active"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*4[\\s]*10f259e906e5[\\s]*running.fmw[\\s]*PULLED[\\s]*1[\\s]*austinApartments.fmw[\\s]*QUEUED[\\s]*$", }, { @@ -510,6 +517,7 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, body: responseV3Completed, args: []string{"jobs", "--completed"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*3[\\s]*387f74cd4e1f[\\s]*austinApartments.fmw[\\s]*SUCCESS[\\s]*2[\\s]*10f259e906e5[\\s]*none2none.fmw[\\s]*FME_FAILURE[\\s]*$", }, { @@ -517,6 +525,7 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, body: responseV3Queued, args: []string{"jobs", "--queued"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*1[\\s]*austinApartments.fmw[\\s]*QUEUED[\\s]*$", }, { @@ -524,6 +533,7 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, body: responseV3Queued, args: []string{"jobs", "--queued", "--no-headers"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "^[\\s]*1[\\s]*austinApartments.fmw[\\s]*QUEUED[\\s]*$", }, { @@ -531,6 +541,7 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, args: []string{"jobs", "--queued", "--json"}, body: responseV3Queued, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputJson: responseV3Queued, }, { @@ -538,34 +549,39 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, args: []string{"jobs", "--queued", "--output=json"}, body: responseV3Queued, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputJson: responseV3Queued, }, { - name: "workspace flag requires repository", - statusCode: http.StatusOK, - args: []string{"jobs", "--workspace", "austinApartments.fmw"}, - wantErrText: "required flag(s) \"repository\" not set", - body: responseV3Completed, + name: "workspace flag requires repository", + statusCode: http.StatusOK, + args: []string{"jobs", "--workspace", "austinApartments.fmw"}, + wantErrText: "required flag(s) \"repository\" not set", + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) + body: responseV3Completed, }, { - name: "queued and active can't both be specified", - statusCode: http.StatusOK, - args: []string{"jobs", "--queued", "--active"}, - wantErrText: "if any flags in the group [active queued] are set none of the others can be; [active queued] were all set", - body: responseV3Completed, + name: "queued and active can't both be specified", + statusCode: http.StatusOK, + args: []string{"jobs", "--queued", "--active"}, + wantErrText: "if any flags in the group [active queued] are set none of the others can be; [active queued] were all set", + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) + body: responseV3Completed, }, { - name: "running and active can't both be specified", - statusCode: http.StatusOK, - args: []string{"jobs", "--running", "--active"}, - wantErrText: "if any flags in the group [active running] are set none of the others can be; [active running] were all set", - body: responseV3Completed, + name: "running and active can't both be specified", + statusCode: http.StatusOK, + args: []string{"jobs", "--running", "--active"}, + wantErrText: "if any flags in the group [active running] are set none of the others can be; [active running] were all set", + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) + body: responseV3Completed, }, { name: "get jobs by repository", statusCode: http.StatusOK, args: []string{"jobs", "--repository", "Samples"}, wantFormParams: map[string]string{"repository": "Samples"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) body: responseV3Completed, }, { @@ -573,6 +589,7 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, args: []string{"jobs", "--repository", "Samples", "--workspace", "austinApartments.fmw"}, wantFormParams: map[string]string{"workspace": "austinApartments.fmw", "repository": "Samples"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) body: responseV3Completed, }, { @@ -580,6 +597,7 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, args: []string{"jobs", "--source-id", "some-source-id"}, wantFormParams: map[string]string{"sourceID": "some-source-id"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) body: responseV3Completed, }, { @@ -587,6 +605,7 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, args: []string{"jobs", "--user-name", "admin"}, wantFormParams: map[string]string{"userName": "admin"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) body: responseV3Completed, }, { @@ -594,6 +613,7 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, args: []string{"jobs", "--source-type", "source"}, wantFormParams: map[string]string{"sourceType": "source"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) body: responseV3Completed, }, { @@ -601,6 +621,7 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, body: responseV3Completed, args: []string{"jobs", "--completed", "--output", "custom-columns=CPU:.cpuTime,FEATURES OUTPUT:.result.numFeaturesOutput"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "^[\\s]*CPU[\\s]*FEATURES OUTPUT[\\s]*994[\\s]*49[\\s]*697[\\s]*0[\\s]*$", }, { @@ -608,6 +629,7 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, args: []string{"jobs", "--id", "1"}, body: responseV3SingleJob, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputRegex: "^[\\s]*JOB ID[\\s]*ENGINE NAME[\\s]*WORKSPACE[\\s]*STATUS[\\s]*1[\\s]*145929514b24[\\s]*none2none.fmw[\\s]*ABORTED[\\s]*$", }, { @@ -615,13 +637,15 @@ func TestJobs(t *testing.T) { statusCode: http.StatusOK, args: []string{"jobs", "--id", "1", "--json"}, body: responseV3SingleJob, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) wantOutputJson: responseV3SingleJobOutput, }, { - name: "get single job does not exist", - statusCode: http.StatusNotFound, - args: []string{"jobs", "--id", "243"}, - wantErrText: "404 Not Found", + name: "get single job does not exist", + statusCode: http.StatusNotFound, + args: []string{"jobs", "--id", "243"}, + fmeflowBuild: 24733, // Force V3 API usage (<= 25208 threshold) + wantErrText: "404 Not Found", }, } diff --git a/cmd/projects_download.go b/cmd/projects_download.go index 2e8b8c7..19e6203 100644 --- a/cmd/projects_download.go +++ b/cmd/projects_download.go @@ -38,6 +38,8 @@ type projectExportSelectedItem struct { ID string `json:"id"` } +var projectDownloadV4BuildThreshold = 23766 + // backupCmd represents the backup command func newProjectDownloadCmd() *cobra.Command { f := projectsDownloadFlags{} @@ -49,7 +51,7 @@ func newProjectDownloadCmd() *cobra.Command { // get build to decide if we should use v3 or v4 if f.apiVersion == "" { fmeflowBuild := viper.GetInt("build") - if fmeflowBuild < projectUploadV4BuildThreshold { + if fmeflowBuild < projectDownloadV4BuildThreshold { f.apiVersion = apiVersionFlagV3 } else { f.apiVersion = apiVersionFlagV4 diff --git a/cmd/projects_upload.go b/cmd/projects_upload.go index 43fe83d..a781a7f 100644 --- a/cmd/projects_upload.go +++ b/cmd/projects_upload.go @@ -95,7 +95,28 @@ type ProjectUploadV4 struct { Request ProjectImportRun `json:"request"` } -var projectUploadV4BuildThreshold = 23766 +type ProjectTaskV4 struct { + ID int `json:"id"` + Type string `json:"type"` + Username string `json:"username"` + StartDate time.Time `json:"startDate"` + FinishedDate time.Time `json:"finishedDate"` + Status string `json:"status"` + ProjectName any `json:"projectName"` + SuccessTopic string `json:"successTopic"` + FailureTopic string `json:"failureTopic"` + ResourceName string `json:"resourceName"` + PackagePath string `json:"packagePath"` + PackageName string `json:"packageName"` + ImportMode string `json:"importMode"` + ProjectsImportMode string `json:"projectsImportMode"` + PauseNotifications bool `json:"pauseNotifications"` + Result string `json:"result"` + ExcludeSensitiveInfo bool `json:"excludeSensitiveInfo"` + DisableProjectItems bool `json:"disableProjectItems"` +} + +var projectUploadV4BuildThreshold = 25049 func newProjectUploadCmd() *cobra.Command { f := projectUploadFlags{} @@ -109,7 +130,7 @@ func newProjectUploadCmd() *cobra.Command { - Using the --selected-items flag will import only the items specified. The default is to import all items in the package.`, PreRunE: func(cmd *cobra.Command, args []string) error { // get build to decide if we should use v3 or v4 - // FME Server 2022.0 and later can use v4. Otherwise fall back to v3 + // FME Server 2025.0 and later can use v4. Otherwise fall back to v3 if f.apiVersion == "" { fmeflowBuild := viper.GetInt("build") if fmeflowBuild < projectUploadV4BuildThreshold { @@ -242,7 +263,7 @@ func projectUploadRun(f *projectUploadFlags) func(cmd *cobra.Command, args []str return err } - url = "/fmeapiv4/migrations/imports/upload" + url = "/fmeapiv4/projects/imports/upload" request, err = buildFmeFlowRequest(url, "POST", &requestBody) if err != nil { return err @@ -283,7 +304,7 @@ func projectUploadRun(f *projectUploadFlags) func(cmd *cobra.Command, args []str // We have to do a get on the import to see if the status is ready ready := false tries := 0 - url = "/fmeapiv4/migrations/imports/" + taskId + url = "/fmeapiv4/projects/tasks/" + taskId request, err = buildFmeFlowRequest(url, "GET", nil) if err != nil { return err @@ -308,14 +329,14 @@ func projectUploadRun(f *projectUploadFlags) func(cmd *cobra.Command, args []str return err } - var importStatus ProjectUploadV4 + var importStatus ProjectTaskV4 if err := json.Unmarshal(responseData, &importStatus); err != nil { return err } // check if it is ready - if importStatus.Status == "ready" { + if importStatus.Status == "success" { ready = true - } else if importStatus.Status == "generating_preview" { + } else if importStatus.Status == "generatingPreview" || importStatus.Status == "submitted" { // if it is still generating the preview, wait a second and try again if !jsonOutput && !f.getSelectable { fmt.Fprint(cmd.OutOrStdout(), ".") @@ -333,7 +354,7 @@ func projectUploadRun(f *projectUploadFlags) func(cmd *cobra.Command, args []str } // get the selectable items from the preview - url = "/fmeapiv4/migrations/imports/" + taskId + "/items" + url = "/fmeapiv4/projects/imports/" + taskId + "/items" // set up the URL to query request, err := buildFmeFlowRequest(url, "GET", nil) if err != nil { @@ -366,7 +387,7 @@ func projectUploadRun(f *projectUploadFlags) func(cmd *cobra.Command, args []str // if we are just outputing the selectable items for this package, just output them, delete the import and return if f.getSelectable { // delete the import since we are just getting the selectable items - url = "/fmeapiv4/migrations/imports/" + taskId + url = "/fmeapiv4/projects/imports/" + taskId request, err = buildFmeFlowRequest(url, "DELETE", nil) if err != nil { return err @@ -402,6 +423,7 @@ func projectUploadRun(f *projectUploadFlags) func(cmd *cobra.Command, args []str // if we are interactive, we want to prompt the user to select items from the list of selectable ones if f.interactive { + fmt.Fprint(cmd.OutOrStdout(), "Prompting User for items...\n") // store the item ids and types in a string array so that we can prompt the user to select items var items []string for _, element := range selectableItems.Items { @@ -475,7 +497,7 @@ func projectUploadRun(f *projectUploadFlags) func(cmd *cobra.Command, args []str if !f.getSelectable { // finally, we can run the import - url = "/fmeapiv4/migrations/imports/" + taskId + "/run" + url = "/fmeapiv4/projects/imports/" + taskId + "/run" var run ProjectImportRun // set the run struct run.Overwrite = f.overwrite @@ -490,7 +512,7 @@ func projectUploadRun(f *projectUploadFlags) func(cmd *cobra.Command, args []str // if a topic is specified, add that if f.backupFailureTopic != "" || f.backupSuccessTopic != "" { run.Notification = new(ProjectNotification) - run.Notification.Type = "TOPIC" + run.Notification.Type = "topic" if f.backupSuccessTopic != "" { run.Notification.SuccessTopic = f.backupSuccessTopic } @@ -524,7 +546,7 @@ func projectUploadRun(f *projectUploadFlags) func(cmd *cobra.Command, args []str fmt.Fprintln(cmd.OutOrStdout(), "Project Upload task submitted with id: "+taskId) } else if !f.wait { // if we are outputting json and not waiting, do a get on the task and output that - url = "/fmeapiv4/migrations/imports/" + taskId + url = "/fmeapiv4/projects/imports/" + taskId request, err = buildFmeFlowRequest(url, "GET", nil) if err != nil { return err @@ -553,7 +575,7 @@ func projectUploadRun(f *projectUploadFlags) func(cmd *cobra.Command, args []str // if we are waiting for the import to complete, we have to loop until it is done if f.wait { finished := false - url = "/fmeapiv4/migrations/imports/" + taskId + url = "/fmeapiv4/projects/imports/" + taskId request, err = buildFmeFlowRequest(url, "GET", nil) if err != nil { return err diff --git a/cmd/projects_upload_test.go b/cmd/projects_upload_test.go index 5eba804..16564df 100644 --- a/cmd/projects_upload_test.go +++ b/cmd/projects_upload_test.go @@ -26,6 +26,27 @@ func TestProjectUpload(t *testing.T) { FailureTopic: "MIGRATION_ASYNC_JOB_FAILURE", } + TaskGetStruct := ProjectTaskV4{ + ID: 1, + Type: "projectImport", + Username: "admin", + StartDate: time.Date(2025, 10, 23, 21, 16, 44, 720000000, time.UTC), + FinishedDate: time.Date(2025, 10, 23, 21, 16, 44, 867000000, time.UTC), + Status: "generatingPreview", + ProjectName: nil, + SuccessTopic: "", + FailureTopic: "", + ResourceName: "", + PackagePath: "", + PackageName: "ProjectPackage.fsproject", + ImportMode: "overwrite", + ProjectsImportMode: "overwrite", + PauseNotifications: false, + Result: "Successful preview import", + ExcludeSensitiveInfo: false, + DisableProjectItems: false, + } + ProjectGetStruct := ProjectUploadV4{ JobID: 1, Status: "importing", @@ -97,7 +118,7 @@ func TestProjectUpload(t *testing.T) { if strings.Contains(r.URL.Path, "upload") { // set a location header - w.Header().Set("Location", "http://localhost:8080/fmeapiv4/migrations/imports/1") + w.Header().Set("Location", "http://localhost:8080/fmeapiv4/projects/imports/1") w.WriteHeader(http.StatusCreated) // check if there is a URL argument @@ -105,25 +126,43 @@ func TestProjectUpload(t *testing.T) { urlParams := r.Form if urlParams.Get("skipPreview") != "" { // set status to generating preview - ProjectGetStruct.Status = "generating_preview" + TaskGetStruct.Status = "generatingPreview" } else { - // set status to ready - ProjectGetStruct.Status = "ready" + // set status to success + ProjectGetStruct.Status = "success" } } else if strings.Contains(r.URL.Path, "run") && r.Method == "POST" { w.WriteHeader(http.StatusAccepted) - require.Contains(t, r.URL.Path, "migrations/imports/1/run") + require.Contains(t, r.URL.Path, "projects/imports/1/run") // set status to importing ProjectGetStruct.Status = "importing" - } else if strings.Contains(r.URL.Path, "migrations/imports/1/items") && r.Method == "GET" { + } else if strings.Contains(r.URL.Path, "projects/imports/1/items") && r.Method == "GET" { w.WriteHeader(http.StatusOK) // return the test list of selectable items _, err := w.Write([]byte(ProjectItemsJson)) require.NoError(t, err) // set status to importing ProjectGetStruct.Status = "importing" - } else if strings.Contains(r.URL.Path, "migrations/imports/1") && r.Method == "GET" { + } else if strings.Contains(r.URL.Path, "projects/tasks/1") && r.Method == "GET" { + w.WriteHeader(http.StatusOK) + if getCount < 1 { + getCount++ + } else { + if TaskGetStruct.Status == "generatingPreview" { + //set status to ready + TaskGetStruct.Status = "success" + } + getCount = 0 + } + // marshal the struct to json + projectGetJson, err := json.Marshal(TaskGetStruct) + require.NoError(t, err) + + // write the json to the response + _, err = w.Write(projectGetJson) + require.NoError(t, err) + } else if strings.Contains(r.URL.Path, "projects/imports/1") && r.Method == "GET" { w.WriteHeader(http.StatusOK) if getCount < 1 { getCount++ @@ -131,9 +170,6 @@ func TestProjectUpload(t *testing.T) { if ProjectGetStruct.Status == "importing" { // set status to imported ProjectGetStruct.Status = "imported" - } else if ProjectGetStruct.Status == "generating_preview" { - //set status to ready - ProjectGetStruct.Status = "ready" } getCount = 0 } @@ -144,7 +180,8 @@ func TestProjectUpload(t *testing.T) { // write the json to the response _, err = w.Write(projectGetJson) require.NoError(t, err) - } else if strings.Contains(r.URL.Path, "migrations/imports/1") && r.Method == "DELETE" { + + } else if strings.Contains(r.URL.Path, "projects/imports/1") && r.Method == "DELETE" { w.WriteHeader(http.StatusNoContent) } else { w.WriteHeader(http.StatusNotFound) diff --git a/cmd/testFunctions.go b/cmd/testFunctions.go index d37518f..6d24f3e 100644 --- a/cmd/testFunctions.go +++ b/cmd/testFunctions.go @@ -86,7 +86,7 @@ func runTests(tcs []testCase, t *testing.T) { if tc.fmeflowBuild != 0 { viper.Set("build", tc.fmeflowBuild) } else { - viper.Set("build", 23776) + viper.Set("build", 25645) } }