(t *testing.T)
| 89 | } |
| 90 | |
| 91 | func 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 | |
| 127 | func TestRemoveGhostDirective(t *testing.T) { |
| 128 | tests := []struct { |
nothing calls this directly
no test coverage detected