MCPcopy Index your code
hub / github.com/coder/coder / TestUpdateCheck_NewVersion

Function TestUpdateCheck_NewVersion

coderd/updatecheck_test.go:20–77  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestUpdateCheck_NewVersion(t *testing.T) {
21 t.Parallel()
22
23 tests := []struct {
24 name string
25 resp github.RepositoryRelease
26 want codersdk.UpdateCheckResponse
27 }{
28 {
29 name: "New version",
30 resp: github.RepositoryRelease{
31 TagName: github.String("v99.999.999"),
32 HTMLURL: github.String("https://someurl.com"),
33 },
34 want: codersdk.UpdateCheckResponse{
35 Current: false,
36 Version: "v99.999.999",
37 URL: "https://someurl.com",
38 },
39 },
40 {
41 name: "Same version",
42 resp: github.RepositoryRelease{
43 TagName: github.String(buildinfo.Version()),
44 HTMLURL: github.String("https://someurl.com"),
45 },
46 want: codersdk.UpdateCheckResponse{
47 Current: true,
48 Version: buildinfo.Version(),
49 URL: "https://someurl.com",
50 },
51 },
52 }
53 for _, tt := range tests {
54 t.Run(tt.name, func(t *testing.T) {
55 t.Parallel()
56
57 srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
58 b, err := json.Marshal(tt.resp)
59 assert.NoError(t, err)
60 w.Write(b)
61 }))
62 defer srv.Close()
63
64 client := coderdtest.New(t, &coderdtest.Options{
65 UpdateCheckOptions: &updatecheck.Options{
66 URL: srv.URL,
67 },
68 })
69
70 ctx := testutil.Context(t, testutil.WaitLong)
71
72 got, err := client.UpdateCheck(ctx)
73 require.NoError(t, err)
74 require.Equal(t, tt.want, got)
75 })
76 }
77}

Callers

nothing calls this directly

Calls 10

CloseMethod · 0.95
VersionFunction · 0.92
NewFunction · 0.92
ContextFunction · 0.92
UpdateCheckMethod · 0.80
RunMethod · 0.65
WriteMethod · 0.65
StringMethod · 0.45
MarshalMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected