@@ -25,104 +25,82 @@ var (
25
25
26
26
func TestFrontendMainPage (t * testing.T ) {
27
27
defer postgres .ResetTestDB (testDB , t )
28
- defer postgres .ResetTestDB (testDB , t )
29
- for _ , exp := range []struct {
30
- name string
31
- exps []string
28
+
29
+ processVersions (
30
+ experiment .NewContext (context .Background (), internal .ExperimentSymbolHistoryMainPage ),
31
+ t , testModules )
32
+
33
+ const modulePath = "example.com/symbols"
34
+ for _ , test := range []struct {
35
+ name , pkgPath string
36
+ want htmlcheck.Checker
32
37
}{
33
38
{
34
- "no experiment" ,
35
- []string {
36
- internal .ExperimentSymbolHistoryMainPage ,
37
- },
39
+ "main page symbols - one version all symbols" ,
40
+ modulePath ,
41
+ in ("" ,
42
+ in ("#F" ,
43
+ in (".Documentation-sinceVersion" , hasText ("" ))),
44
+ in ("#I1" ,
45
+ in (".Documentation-sinceVersion" , hasText ("" ))),
46
+ in ("#I2" ,
47
+ in (".Documentation-sinceVersion" , hasText ("" ))),
48
+ in ("#Int" ,
49
+ in (".Documentation-sinceVersion" , hasText ("" ))),
50
+ in ("#Num" ,
51
+ in (".Documentation-sinceVersion" , hasText ("" ))),
52
+ in ("#S1" ,
53
+ in (".Documentation-sinceVersion" , hasText ("" ))),
54
+ in ("#S2" ,
55
+ in (".Documentation-sinceVersion" , hasText ("" ))),
56
+ in ("#String" ,
57
+ in (".Documentation-sinceVersion > .Documentation-sinceVersionVersion" , hasText ("v1.1.0" ))),
58
+ in ("#T" ,
59
+ in (".Documentation-sinceVersion" , hasText ("" ))),
60
+ in ("#TF" ,
61
+ in (".Documentation-sinceVersion" , hasText ("" ))),
62
+ ),
38
63
},
39
64
{
40
- "experiment insert and read symbol_history" ,
41
- []string {
42
- internal .ExperimentReadSymbolHistory ,
43
- internal .ExperimentSymbolHistoryMainPage ,
44
- },
65
+ "main page hello - multi GOOS default page" ,
66
+ modulePath + "/hello" ,
67
+ // Hello is the only symbol when GOOS is not set, so return the
68
+ // empty string instead of v1.2.0.
69
+ // TODO(https://golang.org/issue/37102): decide whether it makes
70
+ // sense to show the version in this case.
71
+ in ("" , in ("#Hello" ,
72
+ in (".Documentation-sinceVersion" , hasText ("" )))),
45
73
},
74
+ /*
75
+ TODO: fix flaky test and uncomment
76
+ {
77
+ "main page hello - multi GOOS JS page",
78
+ modulePath + "/hello?GOOS=js",
79
+ in("",
80
+ // HelloJS was introduced in v1.1.0, the earliest version of
81
+ // this package. Omit the version, even though it is not the
82
+ // earliest version of the module.
83
+ in("#HelloJS",
84
+ in(".Documentation-sinceVersion", hasText(""))),
85
+ // Hello is not the only symbol when GOOS=js, so show that
86
+ // it was added in v1.2.0.
87
+ in("#Hello",
88
+ in(".Documentation-sinceVersion", hasText("v1.2.0")))),
89
+ },
90
+ */
46
91
} {
47
- t .Run (exp .name , func (t * testing.T ) {
48
- exps := append (exp .exps , internal .ExperimentInsertSymbolSearchDocuments )
49
- processVersions (
50
- experiment .NewContext (context .Background (), exps ... ),
51
- t , testModules )
52
-
53
- const modulePath = "example.com/symbols"
54
- for _ , test := range []struct {
55
- name , pkgPath string
56
- want htmlcheck.Checker
57
- }{
58
- {
59
- "main page symbols - one version all symbols" ,
60
- modulePath ,
61
- in ("" ,
62
- in ("#F" ,
63
- in (".Documentation-sinceVersion" , hasText ("" ))),
64
- in ("#I1" ,
65
- in (".Documentation-sinceVersion" , hasText ("" ))),
66
- in ("#I2" ,
67
- in (".Documentation-sinceVersion" , hasText ("" ))),
68
- in ("#Int" ,
69
- in (".Documentation-sinceVersion" , hasText ("" ))),
70
- in ("#Num" ,
71
- in (".Documentation-sinceVersion" , hasText ("" ))),
72
- in ("#S1" ,
73
- in (".Documentation-sinceVersion" , hasText ("" ))),
74
- in ("#S2" ,
75
- in (".Documentation-sinceVersion" , hasText ("" ))),
76
- in ("#String" ,
77
- in (".Documentation-sinceVersion > .Documentation-sinceVersionVersion" , hasText ("v1.1.0" ))),
78
- in ("#T" ,
79
- in (".Documentation-sinceVersion" , hasText ("" ))),
80
- in ("#TF" ,
81
- in (".Documentation-sinceVersion" , hasText ("" ))),
82
- ),
83
- },
84
- {
85
- "main page hello - multi GOOS default page" ,
86
- modulePath + "/hello" ,
87
- // Hello is the only symbol when GOOS is not set, so return the
88
- // empty string instead of v1.2.0.
89
- // TODO(https://golang.org/issue/37102): decide whether it makes
90
- // sense to show the version in this case.
91
- in ("" , in ("#Hello" ,
92
- in (".Documentation-sinceVersion" , hasText ("" )))),
93
- },
94
- /*
95
- TODO: fix flaky test and uncomment
96
- {
97
- "main page hello - multi GOOS JS page",
98
- modulePath + "/hello?GOOS=js",
99
- in("",
100
- // HelloJS was introduced in v1.1.0, the earliest version of
101
- // this package. Omit the version, even though it is not the
102
- // earliest version of the module.
103
- in("#HelloJS",
104
- in(".Documentation-sinceVersion", hasText(""))),
105
- // Hello is not the only symbol when GOOS=js, so show that
106
- // it was added in v1.2.0.
107
- in("#Hello",
108
- in(".Documentation-sinceVersion", hasText("v1.2.0")))),
109
- },
110
- */
111
- } {
112
- t .Run (test .name , func (t * testing.T ) {
113
- urlPath := fmt .Sprintf ("/%s" , test .pkgPath )
114
- body := getFrontendPage (t , urlPath , exps ... )
115
- doc , err := html .Parse (strings .NewReader (body ))
116
- if err != nil {
117
- t .Fatal (err )
118
- }
119
- if err := test .want (doc ); err != nil {
120
- if testing .Verbose () {
121
- html .Render (os .Stdout , doc )
122
- }
123
- t .Error (err )
124
- }
125
- })
92
+ t .Run (test .name , func (t * testing.T ) {
93
+ urlPath := fmt .Sprintf ("/%s" , test .pkgPath )
94
+ body := getFrontendPage (t , urlPath , internal .ExperimentSymbolHistoryMainPage )
95
+ doc , err := html .Parse (strings .NewReader (body ))
96
+ if err != nil {
97
+ t .Fatal (err )
98
+ }
99
+ if err := test .want (doc ); err != nil {
100
+ if testing .Verbose () {
101
+ html .Render (os .Stdout , doc )
102
+ }
103
+ t .Error (err )
126
104
}
127
105
})
128
106
}
0 commit comments