Skip to content

Commit

Permalink
tests: ensure that given version is downloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
tauraamui committed Jun 23, 2023
1 parent 1853ebf commit f08839d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions data/lang/lang_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,26 @@ func TestRunWithNoArgsDownloadsFilesAndUsesLatestVersion(t *testing.T) {
is.True(ok) // did not generate Go src from language data
}

func TestRunWithVersionArgDownloadsFilesAndUsesGivenVersion(t *testing.T) {
// the comments next to the "is" asserts show up as explanations in the stderr on failure
is := is.New(t)

mockFS := buildMockFS()

visitedURLs := []string{}
is.NoErr(run(mockFS, buildMockHTTPGet(&visitedURLs), []string{"lang.test", "-version=1.19.4"}))

is.Equal(len(visitedURLs), 4) // should have downloaded files
is.True(strings.HasSuffix(visitedURLs[1], "1.19.4.json")) // should have downloaded latest available version

langDir, ok := mockFS.files["fil-ph"]
is.True(ok) // did not create language parent directory
is.True(langDir.Mode.IsDir())

_, ok = mockFS.files["fil-ph/fil_ph.go"]
is.True(ok) // did not generate Go src from language data
}

func TestRunWithEnUSArgFileGeneratesENUsLangNoDownloads(t *testing.T) {
// the comments next to the "is" asserts show up as explanations in the stderr on failure
is := is.New(t)
Expand Down

0 comments on commit f08839d

Please sign in to comment.