aboutsummaryrefslogtreecommitdiff
path: root/dbstore/sqlfs_test.go
blob: c8cb345f58007daaebca8cb056f24a2b4e65f88f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package dbstore

import (
  "testing"
)

func TestGetQuery(t *testing.T) {
  tests := []struct {
    name string
    val string
    exp bool
  } {
    { "pass", "init", true },
    { "fail", "invalid", false },
  }

  for _, test := range(tests) {
    t.Run(test.name, func(t *testing.T) {
      got, err := getQuery(test.val)
      if err != nil && test.exp {
        t.Error(err)
      } else if err == nil && !test.exp {
        t.Errorf("got %v, exp error", got)
      }
    })
  }
}

func TestGetQueries(t *testing.T) {
  tests := []struct {
    name string
    vals []string
    exp bool
  } {
    { "pass", []string { "init" }, true },
    { "fail", []string { "invalid" }, false },
  }

  for _, test := range(tests) {
    t.Run(test.name, func(t *testing.T) {
      got, err := getQueries(test.vals)
      if err != nil && test.exp {
        t.Error(err)
      } else if err == nil && !test.exp {
        t.Errorf("got %v, exp error", got)
      }
    })
  }
}