(t *testing.T)
| 147 | } |
| 148 | |
| 149 | func TestResolveLabel(t *testing.T) { |
| 150 | testCases := []struct { |
| 151 | input string |
| 152 | expected string |
| 153 | }{ |
| 154 | { |
| 155 | input: "js", |
| 156 | expected: "js_2", |
| 157 | }, |
| 158 | { |
| 159 | input: "css", |
| 160 | expected: "css_3", |
| 161 | }, |
| 162 | { |
| 163 | input: "linux", |
| 164 | expected: "linux_4", |
| 165 | }, |
| 166 | { |
| 167 | input: "cool_ideas", |
| 168 | expected: "cool_ideas_2", |
| 169 | }, |
| 170 | } |
| 171 | |
| 172 | for idx, tc := range testCases { |
| 173 | func() { |
| 174 | // set up |
| 175 | db := database.InitTestMemoryDB(t) |
| 176 | |
| 177 | database.MustExec(t, fmt.Sprintf("inserting book for test case %d", idx), db, "INSERT INTO books (uuid, label) VALUES (?, ?)", "b1-uuid", "js") |
| 178 | database.MustExec(t, fmt.Sprintf("inserting book for test case %d", idx), db, "INSERT INTO books (uuid, label) VALUES (?, ?)", "b2-uuid", "css_2") |
| 179 | database.MustExec(t, fmt.Sprintf("inserting book for test case %d", idx), db, "INSERT INTO books (uuid, label) VALUES (?, ?)", "b3-uuid", "linux_(1)") |
| 180 | database.MustExec(t, fmt.Sprintf("inserting book for test case %d", idx), db, "INSERT INTO books (uuid, label) VALUES (?, ?)", "b4-uuid", "linux_2") |
| 181 | database.MustExec(t, fmt.Sprintf("inserting book for test case %d", idx), db, "INSERT INTO books (uuid, label) VALUES (?, ?)", "b5-uuid", "linux_3") |
| 182 | database.MustExec(t, fmt.Sprintf("inserting book for test case %d", idx), db, "INSERT INTO books (uuid, label) VALUES (?, ?)", "b6-uuid", "cool_ideas") |
| 183 | |
| 184 | // execute |
| 185 | tx, err := db.Begin() |
| 186 | if err != nil { |
| 187 | t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error()) |
| 188 | } |
| 189 | |
| 190 | got, err := resolveLabel(tx, tc.input) |
| 191 | if err != nil { |
| 192 | t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error()) |
| 193 | } |
| 194 | tx.Rollback() |
| 195 | |
| 196 | assert.Equal(t, got, tc.expected, fmt.Sprintf("output mismatch for test case %d", idx)) |
| 197 | }() |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | func TestSyncDeleteNote(t *testing.T) { |
| 202 | t.Run("exists on server only", func(t *testing.T) { |
nothing calls this directly
no test coverage detected