From f08839daf1d53cca7d2bf07e29c63f25e4595c08 Mon Sep 17 00:00:00 2001 From: tauraamui Date: Fri, 23 Jun 2023 12:46:28 +0100 Subject: [PATCH] tests: ensure that given version is downloaded --- data/lang/lang_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/data/lang/lang_test.go b/data/lang/lang_test.go index 0e84d4ac..7ff80455 100644 --- a/data/lang/lang_test.go +++ b/data/lang/lang_test.go @@ -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)