| 104 | } |
| 105 | |
| 106 | func TestErrorReadingFile(t *testing.T) { |
| 107 | commandLineFile, _ := ioutil.TempFile("", "") |
| 108 | defer os.Remove(commandLineFile.Name()) |
| 109 | |
| 110 | if err := ioutil.WriteFile(commandLineFile.Name(), []byte("bogus value"), 0644); err != nil { |
| 111 | t.Fatalf("Error creating tempfile: %v", err) |
| 112 | } |
| 113 | |
| 114 | loadingRules := ClientConfigLoadingRules{ |
| 115 | ExplicitPath: commandLineFile.Name(), |
| 116 | } |
| 117 | |
| 118 | _, err := loadingRules.Load() |
| 119 | if err == nil { |
| 120 | t.Fatalf("Expected error for unloadable file, got none") |
| 121 | } |
| 122 | if !strings.Contains(err.Error(), commandLineFile.Name()) { |
| 123 | t.Fatalf("Expected error about '%s', got %s", commandLineFile.Name(), err.Error()) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | func TestErrorReadingNonFile(t *testing.T) { |
| 128 | tmpdir, err := ioutil.TempDir("", "") |