MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestDatabaseXattrConfigHandlingForDBConfigUpdate

Function TestDatabaseXattrConfigHandlingForDBConfigUpdate

rest/api_test.go:2912–2958  ·  view source on GitHub ↗

TestDatabaseXattrConfigHandlingForDBConfigUpdate: - Create database with xattrs enabled - Test updating the config to disable the use of xattrs in this database through replacing + upserting the config - Assert error code is returned and response contains error string

(t *testing.T)

Source from the content-addressed store, hash-verified

2910// - Test updating the config to disable the use of xattrs in this database through replacing + upserting the config
2911// - Assert error code is returned and response contains error string
2912func TestDatabaseXattrConfigHandlingForDBConfigUpdate(t *testing.T) {
2913 base.LongRunningTest(t)
2914 const (
2915 dbName = "db1"
2916 errResp = "sync gateway requires enable_shared_bucket_access=true"
2917 )
2918
2919 testCases := []struct {
2920 name string
2921 upsertConfig bool
2922 }{
2923 {
2924 name: "POST update",
2925 upsertConfig: true,
2926 },
2927 {
2928 name: "PUT update",
2929 upsertConfig: false,
2930 },
2931 }
2932 for _, testCase := range testCases {
2933 t.Run(testCase.name, func(t *testing.T) {
2934 rt := NewRestTester(t, &RestTesterConfig{
2935 PersistentConfig: true,
2936 })
2937 defer rt.Close()
2938
2939 dbConfig := rt.NewDbConfig()
2940
2941 resp := rt.CreateDatabase(dbName, dbConfig)
2942 RequireStatus(t, resp, http.StatusCreated)
2943 rt.WaitForDBOnline()
2944
2945 dbConfig.EnableXattrs = base.Ptr(false)
2946
2947 if testCase.upsertConfig {
2948 resp = rt.UpsertDbConfig(dbName, dbConfig)
2949 RequireStatus(t, resp, http.StatusInternalServerError)
2950 assert.Contains(t, resp.Body.String(), errResp)
2951 } else {
2952 resp = rt.ReplaceDbConfig(dbName, dbConfig)
2953 RequireStatus(t, resp, http.StatusInternalServerError)
2954 assert.Contains(t, resp.Body.String(), errResp)
2955 }
2956 })
2957 }
2958}
2959
2960// TestCreateDBWithXattrsDisabled:
2961// - Test that you cannot create a database with xattrs disabled

Callers

nothing calls this directly

Calls 13

CloseMethod · 0.95
NewDbConfigMethod · 0.95
CreateDatabaseMethod · 0.95
WaitForDBOnlineMethod · 0.95
UpsertDbConfigMethod · 0.95
ReplaceDbConfigMethod · 0.95
LongRunningTestFunction · 0.92
PtrFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85
RunMethod · 0.65
ContainsMethod · 0.65

Tested by

no test coverage detected