Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show nicer error when version does not exist (#31)
* Show nicer error when version does not exist * Add very first unit test * Fix test env
- Loading branch information
1 parent
bfa849f
commit e64ec58
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package download | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
func TestGetDownloadLocation(t *testing.T) { | ||
tempDir := t.TempDir() | ||
t.Setenv("HOME", tempDir) | ||
downloadLocation := GetDownloadLocation() | ||
|
||
expectedLocation := filepath.Join(tempDir, ".tfversion", "versions") | ||
if downloadLocation != expectedLocation { | ||
t.Errorf("Expected download location %s, but got %s", expectedLocation, downloadLocation) | ||
} | ||
|
||
_, err := os.Stat(downloadLocation) | ||
if os.IsNotExist(err) { | ||
t.Errorf("Download location directory does not exist: %s", downloadLocation) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters