GitRepositoryManager/app/utils_test.go

37 lines
630 B
Go
Raw Normal View History

2021-11-02 18:19:31 +00:00
package app
import "testing"
func TestGetFileExtension(t *testing.T) {
toTest := map[string]string{
"myYamlFile.yaml": "yaml",
"myTxtFile.txt": "txt",
"myJsonFile.json": "json",
}
for key, value := range toTest {
result, err := getFileExcension(key)
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
if result != value {
t.Errorf("Expected to get %v, instead of this got %v", value, result)
}
}
}
func TestErrorInGetExcensionFile(t *testing.T) {
result, err := getFileExcension("test")
if err == nil {
t.Errorf("Expected to get error, instead of this got result %v", result)
}
}