Skip to content

Commit

Permalink
fixed test mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristina Pathak committed Sep 1, 2022
1 parent d9d787c commit 39eaa08
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (c *Config) AutoDetect() error {
}
c.autoscalingVersion = hpaVersion
c.logger.V(1).Info("autoscaling version detected", "autoscaling-version", c.autoscalingVersion.String())

return nil
}

Expand Down
11 changes: 10 additions & 1 deletion pkg/collector/adapters/config_to_ports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ func TestParserFailed(t *testing.T) {
}

type mockParser struct {
portsFunc func() ([]corev1.ServicePort, error)
portsFunc func() ([]corev1.ServicePort, error)
containerPortsFunc func() ([]corev1.ContainerPort, error)
}

func (m *mockParser) Ports() ([]corev1.ServicePort, error) {
Expand All @@ -216,6 +217,14 @@ func (m *mockParser) Ports() ([]corev1.ServicePort, error) {
return nil, nil
}

func (m *mockParser) ContainerPorts() ([]corev1.ContainerPort, error) {
if m.containerPortsFunc != nil {
return m.containerPortsFunc()
}

return nil, nil
}

func (m *mockParser) ParserName() string {
return "__mock-adapters"
}
4 changes: 4 additions & 0 deletions pkg/collector/parser/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ func (m *mockParser) Ports() ([]corev1.ServicePort, error) {
return nil, nil
}

func (m *mockParser) ContainerPorts() ([]corev1.ContainerPort, error) {
return nil, nil
}

func (m *mockParser) ParserName() string {
return "__mock"
}

0 comments on commit 39eaa08

Please sign in to comment.