Skip to content

Commit

Permalink
test(agent): ✅ logger is required
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuar committed Jul 31, 2024
1 parent 5b46ca9 commit 90fdc93
Show file tree
Hide file tree
Showing 3 changed files with 242 additions and 4 deletions.
3 changes: 2 additions & 1 deletion internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
// https://opensource.org/licenses/MIT

// revive:disable:unused-receiver
//
//go:generate moq -out agent_mocks_test.go . UI Registry SensorTracker
package agent

import (
Expand Down Expand Up @@ -140,7 +142,6 @@ func ForceRegister(value bool) Option {
// then spawns a sensor tracker and the workers to gather sensor data and
// publish it to Home Assistant.
//

//revive:disable:function-length
func (agent *Agent) Run(ctx context.Context, trk SensorTracker, reg Registry) error {
var wg sync.WaitGroup
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions internal/agent/register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,17 @@ func TestAgent_checkRegistration(t *testing.T) {
{
name: "headless",
args: args{path: t.TempDir()},
fields: fields{prefs: headless, headless: true, id: "go-hass-agent-test"},
fields: fields{prefs: headless, headless: true, id: "go-hass-agent-test", logger: slog.Default()},
},
{
name: "headless error",
args: args{path: t.TempDir()},
fields: fields{prefs: headlessErr, headless: true, id: "go-hass-agent-test"},
fields: fields{prefs: headlessErr, headless: true, id: "go-hass-agent-test", logger: slog.Default()},
wantErr: true,
},
{
name: "force register",
fields: fields{prefs: alreadyRegistered, headless: true, forceRegister: true, id: "go-hass-agent-test"},
fields: fields{prefs: alreadyRegistered, headless: true, forceRegister: true, id: "go-hass-agent-test", logger: slog.Default()},
args: args{path: t.TempDir(), trk: &SensorTrackerMock{ResetFunc: func() {}}},
},
}
Expand Down

0 comments on commit 90fdc93

Please sign in to comment.