-
Notifications
You must be signed in to change notification settings - Fork 89
/
test_results_handler_medium_test.go
56 lines (45 loc) · 1.67 KB
/
test_results_handler_medium_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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// +build medium
// Copyright 2017 The WPT Dashboard Project. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package webapp
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/web-platform-tests/wpt.fyi/shared"
"github.com/web-platform-tests/wpt.fyi/shared/sharedtest"
)
func TestPopulateHomepageData(t *testing.T) {
i, err := sharedtest.NewAEInstance(true)
assert.Nil(t, err)
defer i.Close()
r, _ := i.NewRequest("GET", "/results/?max-count=3", nil)
assert.Nil(t, err)
f, err := populateHomepageData(r)
assert.Nil(t, err)
assert.True(t, f.MaxCount != nil && *f.MaxCount == 3)
r, _ = i.NewRequest("GET", "/results/?products=chrome,safari&diff", nil)
f, err = populateHomepageData(r)
assert.Nil(t, err)
assert.Equal(t, "[\"chrome\",\"safari\"]", f.Products)
assert.Equal(t, true, f.Diff)
r, _ = i.NewRequest("GET", "/results/?before=chrome&after=chrome[experimental]", nil)
f, err = populateHomepageData(r)
assert.Nil(t, err)
assert.Equal(t, "[\"chrome\",\"chrome[experimental]\"]", f.Products)
assert.Equal(t, true, f.Diff)
r, _ = i.NewRequest("GET", "/results/?after=chrome&before=edge", nil)
f, err = populateHomepageData(r)
assert.Nil(t, err)
assert.Equal(t, "[\"edge\",\"chrome\"]", f.Products)
assert.Equal(t, true, f.Diff)
// MasterOnly default query.
r, _ = i.NewRequest("GET", "/results/", nil)
f, err = populateHomepageData(r)
assert.Nil(t, err)
assert.Contains(t, f.Labels, shared.MasterLabel)
r, _ = i.NewRequest("GET", "/results/?sha=0123456789", nil)
f, err = populateHomepageData(r)
assert.Nil(t, err)
assert.NotContains(t, f.Labels, shared.MasterLabel)
}