Skip to content

Commit 4244772

Browse files
committedMar 7, 2025·
fix: add clearComments unit test
1 parent 7a4e784 commit 4244772

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
 

‎sqle/cmd/scannerd/scanners/common/common_test.go

+23
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,26 @@ func TestClearComments(t *testing.T) {
111111
}
112112
}
113113
}
114+
115+
func TestClearLineComments(t *testing.T) {
116+
testCases := []struct {
117+
input string
118+
expected string
119+
}{
120+
{
121+
"SELECT -- id,\n -- name,\n id, name FROM table;",
122+
"SELECT id, name FROM table",
123+
},
124+
{
125+
"SELECT -- id,\n -- name,\n -- age,\n id, name, age FROM table;",
126+
"SELECT id, name, age FROM table",
127+
},
128+
}
129+
130+
for _, tc := range testCases {
131+
actual := clearComments(tc.input)
132+
if actual != tc.expected {
133+
t.Errorf("Expected %s, got %s", tc.expected, actual)
134+
}
135+
}
136+
}

0 commit comments

Comments
 (0)
Please sign in to comment.