Skip to content

Commit

Permalink
Merge pull request #8 from protoconf/avivl/improve-cov
Browse files Browse the repository at this point in the history
Test no  connection to agent
  • Loading branch information
avivl authored Jun 19, 2024
2 parents 47e29a1 + 5c5c01c commit 2759b71
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions protoconfloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,25 @@ func TestConfigFileChangesWithAgent(t *testing.T) {
assert.Equal(t, int32(22), config.Int32(c.GetLogLevel))
}

func TestConfigFileChangesWithNoAgentConnection(t *testing.T) {
c := &pb.CrawlerService{}
handler := slog.NewJSONHandler(io.Discard, nil)
config, err := NewConfiguration(c, "test_config.json", WithLogger(slog.New(handler)))
config.Host = "none"
assert.NoError(t, err)
testDir := t.TempDir()
err = os.WriteFile(filepath.Join(testDir, "config.json"), []byte("{\"logLevel\":21}"), 0644)
require.NoError(t, err)
err = config.LoadConfig(testDir, "config.json")
require.NoError(t, err)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

err = config.WatchConfig(ctx)
require.Error(t, err)

}

func TestGetHostName(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit 2759b71

Please sign in to comment.