@@ -11,7 +11,7 @@ import (
1111)
1212
1313// Function to check how many rows in db has given category & value.
14- func checkRowCount (a * lazydb.LazyDB , category string , value string ) (int , error ) {
14+ func checkRowCount (a * lazydb.LazyDB , category categoryType , value string ) (int , error ) {
1515 // Get Inserted rows
1616 rows , err := a .Query ("SELECT COUNT(*) FROM list_inputted WHERE category=? AND input=?" , category , value )
1717 if err != nil {
@@ -47,7 +47,7 @@ func createTestDB(path string, withData bool) (*lazydb.LazyDB, error) {
4747 }
4848
4949 // Insert data rows
50- sql := `INSERT INTO list_inputted (category, input) VALUES ('abc' ,'123'), ('def' , '123'), ('def' , '456')`
50+ sql := `INSERT INTO list_inputted (category, input) VALUES (45 ,'123'), (56 , '123'), (56 , '456')`
5151 _ , err = a .Exec (sql )
5252 if err != nil {
5353 return nil , err
@@ -70,31 +70,31 @@ func TestInsertValue(t *testing.T) {
7070 // Test case
7171 type testCase struct {
7272 dbPath string
73- category string
73+ category categoryType
7474 value []string
7575 wantErr bool
7676 insertedRow []int // Should have same order as `value`
7777 }
7878
7979 tests := []testCase {
80- // Normal test in same db
81- {db1 , "abc" , []string {"123" }, false , []int {1 }},
82- {db1 , "abc" , []string {"123" }, false , []int {1 }},
83- {db1 , "def" , []string {"123" }, false , []int {1 }},
80+ // Normal test in same db
81+ {db1 , 45 , []string {"123" }, false , []int {1 }},
82+ {db1 , 45 , []string {"123" }, false , []int {1 }},
83+ {db1 , 56 , []string {"123" }, false , []int {1 }},
8484
8585 // Duplicate Test
86- {"test2.db" , "abc" , []string {"123" , "123" }, false , []int {1 , 1 }},
87- {"test2.db" , "abc" , []string {"123" , "456" }, false , []int {1 , 1 }},
86+ {"test2.db" , 45 , []string {"123" , "123" }, false , []int {1 , 1 }},
87+ {"test2.db" , 45 , []string {"123" , "456" }, false , []int {1 , 1 }},
8888
8989 // Empty value
90- {"test3.db" , "abc" , []string {}, false , []int {}},
91- {"test4.db" , "" , []string {"123" }, false , []int {1 }},
90+ {"test3.db" , 45 , []string {}, false , []int {}},
91+ {"test4.db" , 0 , []string {"123" }, false , []int {1 }},
9292
9393 // Empty string value
94- {"test5.db" , "abc" , []string {"123" , "" }, false , []int {1 , 0 }},
94+ {"test5.db" , 45 , []string {"123" , "" }, false , []int {1 , 0 }},
9595
9696 // Nil database
97- {"" , "abc" , []string {"123" }, true , []int {1 }},
97+ {"" , 45 , []string {"123" }, true , []int {1 }},
9898 }
9999
100100 // Start testing
@@ -149,15 +149,15 @@ func TestGetHistory(t *testing.T) {
149149
150150 // Prepare test case
151151 type testCase struct {
152- category string
152+ category categoryType
153153 result []string
154154 wantErr bool
155155 }
156156
157157 tests := []testCase {
158- {"abc" , []string {"123" }, false },
159- {"def" , []string {"123" , "456" }, false },
160- {"kk" , []string {}, false },
158+ {45 , []string {"123" }, false },
159+ {56 , []string {"123" , "456" }, false },
160+ {77 , []string {}, false },
161161 }
162162
163163 // Start Testing
@@ -178,13 +178,13 @@ func TestGetHistoryNilDB(t *testing.T) {
178178
179179 // Prepare test case
180180 type testCase struct {
181- category string
181+ category categoryType
182182 result []string
183183 wantErr bool
184184 }
185185
186186 tests := []testCase {
187- {"abc" , []string {"123" }, true },
187+ {45 , []string {"123" }, true },
188188 }
189189
190190 // Start Testing
0 commit comments