From 4691cedb58b34087bcbf6bcaa78e5e9ee4e881c5 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Thu, 4 Jun 2020 10:57:13 +0200 Subject: [PATCH] Add test validating that settings in a bundle cannot be empty --- pkg/proto/v0/settings.pb.micro_test.go | 27 +++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pkg/proto/v0/settings.pb.micro_test.go b/pkg/proto/v0/settings.pb.micro_test.go index 0acc3d473..4ce38bca3 100644 --- a/pkg/proto/v0/settings.pb.micro_test.go +++ b/pkg/proto/v0/settings.pb.micro_test.go @@ -61,7 +61,7 @@ type CustomError struct { testing that saving a settings bundle and retrieving it again works correctly using various setting bundle properties */ -func TestSaveGetSettingsBundleWithNoSettings(t *testing.T) { +func TestSettingsBundleProperties(t *testing.T) { type TestStruct struct { testDataName string BundleKey string @@ -307,6 +307,31 @@ func TestSaveGetSettingsBundleWithNoSettings(t *testing.T) { } } +func TestSettingsBundleWithoutSettings(t *testing.T) { + client := service.Client() + cl := proto.NewBundleService("com.owncloud.api.settings", client) + + createRequest := proto.SaveSettingsBundleRequest{ + SettingsBundle: &proto.SettingsBundle{ + Identifier: &proto.Identifier{ + Extension: "great-extension", + BundleKey: "alices-bundle", + }, + DisplayName: "Alice's Bundle", + }, + } + response, err := cl.SaveSettingsBundle(context.Background(), &createRequest) + assert.Error(t, err) + assert.Nil(t, response) + var errorData CustomError + _ = json.Unmarshal([]byte(err.Error()), &errorData) + assert.Equal(t, "go.micro.client", errorData.ID) + assert.Equal(t, 500, errorData.Code) + assert.Equal(t, "settings: cannot be blank.", errorData.Detail) + assert.Equal(t, "Internal Server Error", errorData.Status) + _ = os.RemoveAll("ocis-settings-store") +} + /** testing that setting getting and listing a settings bundle works correctly with a set of setting definitions */