diff --git a/api/datastore/sql/sql.go b/api/datastore/sql/sql.go index f6fbd7e9d..9b4b47b71 100644 --- a/api/datastore/sql/sql.go +++ b/api/datastore/sql/sql.go @@ -206,7 +206,8 @@ func (ds *sqlStore) UpdateApp(ctx context.Context, newapp *models.App) (*models. if n, err := res.RowsAffected(); err != nil { return err } else if n == 0 { - return models.ErrAppsNotFound + // inside of the transaction, we are querying for the app, so we know that it exists + return nil } return nil }) diff --git a/test/fn-api-tests/apps_api.go b/test/fn-api-tests/apps_api.go index 54f43f7f6..8ed33437b 100644 --- a/test/fn-api-tests/apps_api.go +++ b/test/fn-api-tests/apps_api.go @@ -72,7 +72,7 @@ func CreateApp(t *testing.T, ctx context.Context, fnclient *client.Functions, ap } } -func UpdateApp(t *testing.T, ctx context.Context, fnclient *client.Functions, appName string, config map[string]string) *apps.PatchAppsAppOK { +func CreateUpdateApp(t *testing.T, ctx context.Context, fnclient *client.Functions, appName string, config map[string]string) *apps.PatchAppsAppOK { CreateApp(t, ctx, fnclient, appName, map[string]string{"A": "a"}) cfg := &apps.PatchAppsAppParams{ App: appName, diff --git a/test/fn-api-tests/apps_test.go b/test/fn-api-tests/apps_test.go index 62e52cfb5..cec2c31ed 100644 --- a/test/fn-api-tests/apps_test.go +++ b/test/fn-api-tests/apps_test.go @@ -58,13 +58,29 @@ func TestApps(t *testing.T) { DeleteApp(t, s.Context, s.Client, s.AppName) }) + t.Run("patch-app-with-exact-same-config-data", func(t *testing.T) { + t.Parallel() + s := SetupDefaultSuite() + config := map[string]string{ + "A": "a", + } + + appUpdatePayload := CreateUpdateApp(t, s.Context, s.Client, s.AppName, config) + _, ok := appUpdatePayload.Payload.App.Config["A"] + if !ok { + t.Error("Error during app update: config map misses required entity `A` with value `a`.") + } + + DeleteApp(t, s.Context, s.Client, s.AppName) + }) + t.Run("patch-override-app-config", func(t *testing.T) { t.Parallel() s := SetupDefaultSuite() config := map[string]string{ "A": "b", } - appPayload := UpdateApp(t, s.Context, s.Client, s.AppName, config) + appPayload := CreateUpdateApp(t, s.Context, s.Client, s.AppName, config) val, ok := appPayload.Payload.App.Config["A"] if !ok { t.Error("Error during app config inspect: config map misses required entity `A` with value `a`.") @@ -81,7 +97,7 @@ func TestApps(t *testing.T) { config := map[string]string{ "B": "b", } - appPayload := UpdateApp(t, s.Context, s.Client, s.AppName, config) + appPayload := CreateUpdateApp(t, s.Context, s.Client, s.AppName, config) val, ok := appPayload.Payload.App.Config["B"] if !ok { t.Error("Error during app config inspect: config map misses required entity `B` with value `b`.")