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

Function TestRemovingUserXattr

rest/user_api_test.go:1081–1197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1079 }
1080}
1081func TestRemovingUserXattr(t *testing.T) {
1082 if !base.TestUseXattrs() {
1083 t.Skip("This test only works with XATTRS enabled")
1084 }
1085
1086 if !base.IsEnterpriseEdition() {
1087 t.Skipf("test is EE only - user xattrs")
1088 }
1089
1090 defer db.SuspendSequenceBatching()()
1091
1092 base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll)
1093
1094 testCases := []struct {
1095 name string
1096 autoImport bool
1097 importTrigger func(t *testing.T, rt *RestTester, docKey string)
1098 }{
1099 {
1100 name: "GET",
1101 autoImport: false,
1102 importTrigger: func(t *testing.T, rt *RestTester, docKey string) {
1103 resp := rt.SendAdminRequest("GET", "/{{.keyspace}}/"+docKey, "")
1104 RequireStatus(t, resp, http.StatusOK)
1105 },
1106 },
1107 {
1108 name: "PUT",
1109 autoImport: false,
1110 importTrigger: func(t *testing.T, rt *RestTester, docKey string) {
1111 resp := rt.SendAdminRequest("PUT", "/{{.keyspace}}/"+docKey, "{}")
1112 RequireStatus(t, resp, http.StatusConflict)
1113 },
1114 },
1115 {
1116 name: "Auto",
1117 autoImport: true,
1118 importTrigger: func(t *testing.T, rt *RestTester, docKey string) {
1119 // No op
1120 },
1121 },
1122 }
1123
1124 for _, testCase := range testCases {
1125 t.Run(testCase.name, func(t *testing.T) {
1126 docKey := testCase.name
1127 xattrKey := "myXattr"
1128 channelName := "testChan"
1129
1130 // Sync function to set channel access to whatever xattr is
1131 rt := NewRestTester(t, &RestTesterConfig{
1132 DatabaseConfig: &DatabaseConfig{DbConfig: DbConfig{
1133 AutoImport: testCase.autoImport,
1134 UserXattrKey: &xattrKey,
1135 }},
1136 SyncFn: `
1137 function (doc, oldDoc, meta){
1138 if (meta.xattrs.myXattr !== undefined){

Callers

nothing calls this directly

Calls 15

SendAdminRequestMethod · 0.95
CloseMethod · 0.95
GetSingleDataStoreMethod · 0.95
ContextMethod · 0.95
WaitForConditionMethod · 0.95
GetDatabaseMethod · 0.95
TestUseXattrsFunction · 0.92
IsEnterpriseEditionFunction · 0.92
SuspendSequenceBatchingFunction · 0.92
SetUpTestLoggingFunction · 0.92
MustJSONMarshalFunction · 0.92
JSONUnmarshalFunction · 0.92

Tested by

no test coverage detected