(t *testing.T)
| 45 | } |
| 46 | |
| 47 | func TestFetchLatestStableTag(t *testing.T) { |
| 48 | tagCLI0_1_0 := "cli-v0.1.0" |
| 49 | tagCLI0_1_1 := "cli-v0.1.1" |
| 50 | tagCLI0_1_2Beta := "cli-v0.1.2-beta" |
| 51 | tagCLI0_1_3 := "cli-v0.1.3" |
| 52 | tagServer0_1_0 := "server-v0.1.0" |
| 53 | |
| 54 | prereleaseTrue := true |
| 55 | |
| 56 | testCases := []struct { |
| 57 | releases []*github.RepositoryRelease |
| 58 | expected string |
| 59 | }{ |
| 60 | { |
| 61 | releases: []*github.RepositoryRelease{{TagName: &tagCLI0_1_0}}, |
| 62 | expected: tagCLI0_1_0, |
| 63 | }, |
| 64 | { |
| 65 | releases: []*github.RepositoryRelease{ |
| 66 | {TagName: &tagCLI0_1_1}, |
| 67 | {TagName: &tagServer0_1_0}, |
| 68 | {TagName: &tagCLI0_1_0}, |
| 69 | }, |
| 70 | expected: tagCLI0_1_1, |
| 71 | }, |
| 72 | { |
| 73 | releases: []*github.RepositoryRelease{ |
| 74 | {TagName: &tagServer0_1_0}, |
| 75 | {TagName: &tagCLI0_1_1}, |
| 76 | {TagName: &tagCLI0_1_0}, |
| 77 | }, |
| 78 | expected: tagCLI0_1_1, |
| 79 | }, |
| 80 | { |
| 81 | releases: []*github.RepositoryRelease{ |
| 82 | {TagName: &tagCLI0_1_2Beta, Prerelease: &prereleaseTrue}, |
| 83 | {TagName: &tagServer0_1_0}, |
| 84 | {TagName: &tagCLI0_1_1}, |
| 85 | {TagName: &tagCLI0_1_0}, |
| 86 | }, |
| 87 | expected: tagCLI0_1_1, |
| 88 | }, |
| 89 | { |
| 90 | releases: []*github.RepositoryRelease{ |
| 91 | {TagName: &tagCLI0_1_3}, |
| 92 | {TagName: &tagCLI0_1_2Beta, Prerelease: &prereleaseTrue}, |
| 93 | {TagName: &tagCLI0_1_1}, |
| 94 | {TagName: &tagCLI0_1_0}, |
| 95 | }, |
| 96 | expected: tagCLI0_1_3, |
| 97 | }, |
| 98 | } |
| 99 | |
| 100 | for idx, tc := range testCases { |
| 101 | t.Run(fmt.Sprintf("case %d", idx), func(t *testing.T) { |
| 102 | // setup |
| 103 | gh, mux := setupGithubClient(t) |
| 104 | mux.HandleFunc("/repos/dnote/dnote/releases", func(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected