1
2
3
4
5 package vcweb_test
6
7 import (
8 "cmd/go/internal/vcweb"
9 "io"
10 "log"
11 "net/http"
12 "net/http/httptest"
13 "os"
14 "testing"
15 )
16
17 func TestHelp(t *testing.T) {
18 s, err := vcweb.NewServer(os.DevNull, t.TempDir(), log.Default())
19 if err != nil {
20 t.Fatal(err)
21 }
22 srv := httptest.NewServer(s)
23 defer srv.Close()
24
25 resp, err := http.Get(srv.URL + "/help")
26 if err != nil {
27 t.Fatal(err)
28 }
29 defer resp.Body.Close()
30
31 if resp.StatusCode != 200 {
32 t.Fatal(resp.Status)
33 }
34 body, err := io.ReadAll(resp.Body)
35 if err != nil {
36 t.Fatal(err)
37 }
38 t.Logf("%s", body)
39 }
40
41 func TestOverview(t *testing.T) {
42 s, err := vcweb.NewServer(os.DevNull, t.TempDir(), log.Default())
43 if err != nil {
44 t.Fatal(err)
45 }
46 srv := httptest.NewServer(s)
47 defer srv.Close()
48
49 resp, err := http.Get(srv.URL)
50 if err != nil {
51 t.Fatal(err)
52 }
53 defer resp.Body.Close()
54
55 if resp.StatusCode != 200 {
56 t.Fatal(resp.Status)
57 }
58 body, err := io.ReadAll(resp.Body)
59 if err != nil {
60 t.Fatal(err)
61 }
62 t.Logf("%s", body)
63 }
64
View as plain text