MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestIsGhostEnabled

Function TestIsGhostEnabled

backend/component/ghost/directive_test.go:91–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

89}
90
91func TestIsGhostEnabled(t *testing.T) {
92 tests := []struct {
93 name string
94 content string
95 want bool
96 }{
97 {
98 name: "no directive",
99 content: "ALTER TABLE users ADD COLUMN status VARCHAR(50);",
100 want: false,
101 },
102 {
103 name: "with directive",
104 content: "-- gh-ost = {}\nALTER TABLE users ADD COLUMN status VARCHAR(50);",
105 want: true,
106 },
107 {
108 name: "with flags",
109 content: "-- gh-ost = {\"max-lag-millis\":\"1500\"}\nALTER TABLE users ADD COLUMN status VARCHAR(50);",
110 want: true,
111 },
112 {
113 name: "with comment",
114 content: "-- gh-ost = {} /*default config*/\nALTER TABLE users ADD COLUMN status VARCHAR(50);",
115 want: true,
116 },
117 }
118
119 for _, tt := range tests {
120 t.Run(tt.name, func(t *testing.T) {
121 got := IsGhostEnabled(tt.content)
122 require.Equal(t, tt.want, got)
123 })
124 }
125}
126
127func TestRemoveGhostDirective(t *testing.T) {
128 tests := []struct {

Callers

nothing calls this directly

Calls 3

IsGhostEnabledFunction · 0.85
EqualMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected