forked from remind101/empire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
releases_test.go
33 lines (27 loc) · 940 Bytes
/
releases_test.go
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
package empire
import (
"testing"
"github.com/remind101/empire/pkg/headerutil"
)
func TestReleasesQuery(t *testing.T) {
var (
app = &App{ID: "1234"}
version = 1
sort = "version"
max = 20
order = "desc"
)
rangeHeader := headerutil.Range{
Sort: &sort,
Max: &max,
Order: &order,
}
tests := scopeTests{
{ReleasesQuery{}, "ORDER BY version desc", []interface{}{}},
{ReleasesQuery{Range: rangeHeader}, "ORDER BY version desc LIMIT 20", []interface{}{}},
{ReleasesQuery{App: app, Range: rangeHeader}, "WHERE (app_id = $1) ORDER BY version desc LIMIT 20", []interface{}{"1234"}},
{ReleasesQuery{Version: &version, Range: rangeHeader}, "WHERE (version = $1) ORDER BY version desc LIMIT 20", []interface{}{1}},
{ReleasesQuery{App: app, Version: &version, Range: rangeHeader}, "WHERE (app_id = $1) AND (version = $2) ORDER BY version desc LIMIT 20", []interface{}{"1234", 1}},
}
tests.Run(t)
}