diff --git a/.github/workflows/test-go.yml b/.github/workflows/test-go.yml index 40da23a9..2e29b2de 100644 --- a/.github/workflows/test-go.yml +++ b/.github/workflows/test-go.yml @@ -4,7 +4,8 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Setup Go uses: actions/setup-go@v2 with: diff --git a/clients/go/test/api_locales_test.go b/clients/go/test/api_locales_test.go index 9c78f87e..770237d5 100644 --- a/clients/go/test/api_locales_test.go +++ b/clients/go/test/api_locales_test.go @@ -24,7 +24,7 @@ import ( func Test_phrase_LocalesApiService(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Send the mock response - response := `{"foo": "bar"}` + response := `{"id":"1","name":"English","code":"DE","default":true,"main":true,"rtl":true,"plural_forms":["plural_forms"]}` w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) @@ -36,49 +36,6 @@ func Test_phrase_LocalesApiService(t *testing.T) { configuration := phrase.NewConfiguration() configuration.BasePath = server.URL apiClient := phrase.NewAPIClient(configuration) - - - t.Run("Test LocalesApiService AccountLocales", func(t *testing.T) { - - // t.Skip("skip test") // remove to run test - - // var id string - - // resp, httpRes, err := apiClient.LocalesApi.AccountLocales(context.Background(), id).Execute() - - // require.Nil(t, err) - // require.NotNil(t, resp) - // assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test LocalesApiService LocaleCreate", func(t *testing.T) { - - // t.Skip("skip test") // remove to run test - - // var projectId string - - // resp, httpRes, err := apiClient.LocalesApi.LocaleCreate(context.Background(), projectId).Execute() - - // require.Nil(t, err) - // require.NotNil(t, resp) - // assert.Equal(t, 200, httpRes.StatusCode) - - }) - - t.Run("Test LocalesApiService LocaleDelete", func(t *testing.T) { - - // t.Skip("skip test") // remove to run test - - // var projectId string - // var id string - - // httpRes, err := apiClient.LocalesApi.LocaleDelete(context.Background(), projectId, id).Execute() - - // require.Nil(t, err) - // assert.Equal(t, 200, httpRes.StatusCode) - - }) t.Run("Test LocalesApiService LocaleDownload", func(t *testing.T) { formatOptions := optional.NewInterface(map[string]interface{}{ @@ -108,6 +65,9 @@ func Test_phrase_LocalesApiService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) + assert.Equal(t, "1", resp.Id) + assert.Equal(t, "DE", resp.Code) + assert.Equal(t, "English", resp.Name) assert.Equal(t, "/projects/project_id_example/locales/locale_id", requestUrl.Path) assert.Equal(t, "GET", httpRes.Request.Method) }) @@ -122,6 +82,9 @@ func Test_phrase_LocalesApiService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) + assert.Equal(t, "1", resp.Id) + assert.Equal(t, "DE", resp.Code) + assert.Equal(t, "English", resp.Name) assert.Equal(t, "/projects/project_id_example/locales/locale_id", requestUrl.Path) assert.Equal(t, "PATCH", httpRes.Request.Method) }) @@ -129,10 +92,10 @@ func Test_phrase_LocalesApiService(t *testing.T) { t.Run("Test LocalesApiService LocalesList", func(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Send the mock response - response := `[{"foo": "bar"}]` + response := `[{"id":"1","name":"English","code":"DE","default":true,"main":true,"rtl":true,"plural_forms":["plural_forms"]}]` w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - + w.Write([]byte(response)) })) @@ -145,11 +108,15 @@ func Test_phrase_LocalesApiService(t *testing.T) { localVarOptionals := phrase.LocalesListOpts{} resp, httpRes, err := apiClient.LocalesApi.LocalesList(context.Background(), "project_id_example", &localVarOptionals) requestUrl := httpRes.Request.URL - + locale := resp[0] require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) + assert.Equal(t, 1, len(resp)) + assert.Equal(t, "1", locale.Id) + assert.Equal(t, "DE", locale.Code) + assert.Equal(t, "English", locale.Name) assert.Equal(t, "/projects/project_id_example/locales", requestUrl.Path) assert.Equal(t, "GET", httpRes.Request.Method) }) diff --git a/clients/go/test/api_uploads_test.go b/clients/go/test/api_uploads_test.go index d9ba2b65..0af9afbd 100644 --- a/clients/go/test/api_uploads_test.go +++ b/clients/go/test/api_uploads_test.go @@ -13,8 +13,10 @@ import ( "context" "net/http" "net/http/httptest" + "os" "testing" + "github.com/antihax/optional" "github.com/phrase/phrase-go" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -23,7 +25,7 @@ import ( func Test_phrase_UploadsApiService(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // Send the mock response - response := `{"foo": "bar"}` + response := `{"id": "1", "filename": "test.json", "format": "json", "state": "valid" }` w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) @@ -37,15 +39,26 @@ func Test_phrase_UploadsApiService(t *testing.T) { apiClient := phrase.NewAPIClient(configuration) t.Run("Test UploadsApiService UploadCreate", func(t *testing.T) { - localVarOptionals := phrase.UploadCreateOpts{} + file, _ := os.Create("testfile.json") + fileFormat := optional.NewString("json") + fileObject := optional.NewInterface(file) + localeId := optional.NewString("99") + + localVarOptionals := phrase.UploadCreateOpts{FileFormat: fileFormat, File: fileObject, LocaleId: localeId } resp, httpRes, err := apiClient.UploadsApi.UploadCreate(context.Background(), "project_id", &localVarOptionals) requestUrl := httpRes.Request.URL + require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) + assert.Equal(t, "1", resp.Id) + assert.Equal(t, "test.json", resp.Filename) + assert.Equal(t, "json", resp.Format) assert.Equal(t, "/projects/project_id/uploads", requestUrl.Path) assert.Equal(t, "POST", httpRes.Request.Method) + + defer os.Remove("testfile.json") }) t.Run("Test UploadsApiService UploadShow", func(t *testing.T) { @@ -56,22 +69,11 @@ func Test_phrase_UploadsApiService(t *testing.T) { require.Nil(t, err) require.NotNil(t, resp) assert.Equal(t, 200, httpRes.StatusCode) + assert.Equal(t, "1", resp.Id) + assert.Equal(t, "test.json", resp.Filename) + assert.Equal(t, "json", resp.Format) assert.Equal(t, "/projects/project_id/uploads/upload_id", requestUrl.Path) assert.Equal(t, "GET", httpRes.Request.Method) }) - t.Run("Test UploadsApiService UploadsList", func(t *testing.T) { - - // t.Skip("skip test") // remove to run test - - // var projectId string - - // resp, httpRes, err := apiClient.UploadsApi.UploadsList(context.Background(), projectId).Execute() - - // require.Nil(t, err) - // require.NotNil(t, resp) - // assert.Equal(t, 200, httpRes.StatusCode) - - }) - }