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

Function TestConfigGroupIDValidation

rest/config_test.go:1462–1528  ·  view source on GitHub ↗

CBG-1583 - config group ID EE-only

(t *testing.T)

Source from the content-addressed store, hash-verified

1460
1461// CBG-1583 - config group ID EE-only
1462func TestConfigGroupIDValidation(t *testing.T) {
1463 testCases := []struct {
1464 name string
1465 cfgGroupID string
1466 eeMode bool
1467 expectedError string
1468 }{
1469 {
1470 name: "No change, CE mode",
1471 cfgGroupID: PersistentConfigDefaultGroupID,
1472 eeMode: false,
1473 },
1474 {
1475 name: "No change, EE mode",
1476 cfgGroupID: PersistentConfigDefaultGroupID,
1477 eeMode: true,
1478 },
1479 {
1480 name: "Changed, EE mode",
1481 cfgGroupID: "testGroup",
1482 eeMode: true,
1483 },
1484 {
1485 name: "Changed, CE mode",
1486 cfgGroupID: "testGroup",
1487 eeMode: false,
1488 expectedError: "customization of group_id is only supported in enterprise edition",
1489 },
1490 {
1491 name: "Changed, EE mode, at max length",
1492 cfgGroupID: strings.Repeat("a", persistentConfigGroupIDMaxLength),
1493 eeMode: true,
1494 },
1495 {
1496 name: "Changed, EE mode, over max length",
1497 cfgGroupID: strings.Repeat("a", persistentConfigGroupIDMaxLength+1),
1498 eeMode: true,
1499 expectedError: "group_id must be at most",
1500 },
1501 }
1502 for _, test := range testCases {
1503 t.Run(test.name, func(t *testing.T) {
1504 isEnterpriseEdition := base.IsEnterpriseEdition()
1505 if test.eeMode && !isEnterpriseEdition {
1506 t.Skip("EE mode only test case")
1507 }
1508 if !test.eeMode && isEnterpriseEdition {
1509 t.Skip("CE mode only test case")
1510 }
1511
1512 sc := StartupConfig{
1513 Bootstrap: BootstrapConfig{
1514 ConfigGroupID: test.cfgGroupID,
1515 Server: base.UnitTestUrl(),
1516 UseTLSServer: base.Ptr(base.ServerIsTLS(base.UnitTestUrl())),
1517 },
1518 }
1519 err := sc.Validate(base.TestCtx(t), isEnterpriseEdition)

Callers

nothing calls this directly

Calls 9

ValidateMethod · 0.95
IsEnterpriseEditionFunction · 0.92
UnitTestUrlFunction · 0.92
PtrFunction · 0.92
ServerIsTLSFunction · 0.92
TestCtxFunction · 0.92
RunMethod · 0.65
ContainsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected