Skip to content

Commit

Permalink
removed the useless tests
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Burns <[email protected]>
  • Loading branch information
mattcburns committed Jan 3, 2024
1 parent 98a1172 commit 658753b
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 221 deletions.
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/coocood/freecache v1.2.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
Expand All @@ -75,7 +74,6 @@ require (
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/philippgille/gokv/encoding v0.6.0 // indirect
github.com/philippgille/gokv/util v0.6.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
Expand All @@ -85,8 +83,6 @@ require (
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/stmcginnis/gofish v0.15.1-0.20231121142100-22a60a77be91 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.20.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.20.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ github.com/stmcginnis/gofish v0.15.1-0.20231121142100-22a60a77be91/go.mod h1:BLD
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand All @@ -346,7 +345,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
215 changes: 0 additions & 215 deletions grpc/rpc/diagnostic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package rpc
import (
"context"
"errors"
"fmt"
"testing"

"github.com/bmc-toolbox/bmclib/v2/bmc"
Expand All @@ -12,7 +11,6 @@ import (
"github.com/onsi/gomega"
"github.com/philippgille/gokv"
"github.com/philippgille/gokv/freecache"
"github.com/stretchr/testify/mock"
v1 "github.com/tinkerbell/pbnj/api/v1"
"github.com/tinkerbell/pbnj/grpc/persistence"
"github.com/tinkerbell/pbnj/grpc/taskrunner"
Expand Down Expand Up @@ -150,216 +148,3 @@ func TestConvertEntriesToEvents(t *testing.T) {
})
}
}

func TestDiagnosticService_SystemEventLogRaw(t *testing.T) {
testCases := []struct {
name string
ctx context.Context
in *v1.SystemEventLogRawRequest
expectedLog *v1.SystemEventLogRawResponse
expectedErr error
expectedLogMessage string
}{
{
name: "successful request",
ctx: context.Background(),
in: &v1.SystemEventLogRawRequest{
Authn: &v1.Authn{
Authn: &v1.Authn_DirectAuthn{
DirectAuthn: &v1.DirectAuthn{
Username: "testuser",
},
},
},
Vendor: &v1.Vendor{
Name: "testvendor",
},
},
expectedLog: &v1.SystemEventLogRawResponse{
Log: "test log",
},
expectedErr: nil,
expectedLogMessage: "start Get System Event Log request",
},
{
name: "error creating raw system event log action",
ctx: context.Background(),
in: &v1.SystemEventLogRawRequest{
Authn: &v1.Authn{
Authn: &v1.Authn_DirectAuthn{
DirectAuthn: &v1.DirectAuthn{
Username: "testuser",
},
},
},
Vendor: &v1.Vendor{
Name: "testvendor",
},
},
expectedLog: nil,
expectedErr: errors.New("error creating raw system event log action"),
expectedLogMessage: "start Get System Event Log request",
},
{
name: "error getting raw system event log",
ctx: context.Background(),
in: &v1.SystemEventLogRawRequest{
Authn: &v1.Authn{
Authn: &v1.Authn_DirectAuthn{
DirectAuthn: &v1.DirectAuthn{
Username: "testuser",
},
},
},
Vendor: &v1.Vendor{
Name: "testvendor",
},
},
expectedLog: nil,
expectedErr: errors.New("error getting raw system event log"),
expectedLogMessage: "start Get System Event Log request",
},
}

for _, tc := range testCases {
testCase := tc
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
diagnosticService := NewMockDiagnosticService()
diagnosticService.On("SystemEventLogRaw", testCase.ctx, testCase.in).Return(testCase.expectedLog, testCase.expectedErr)
})
}
}
func TestDiagnosticService_SystemEventLog(t *testing.T) {
testCases := []struct {
name string
ctx context.Context
in *v1.SystemEventLogRequest
expectedEvents []*v1.SystemEventLogEntry
expectedErr error
}{
{
name: "successful request",
ctx: context.Background(),
in: &v1.SystemEventLogRequest{
Authn: &v1.Authn{
Authn: &v1.Authn_DirectAuthn{
DirectAuthn: &v1.DirectAuthn{
Username: "testuser",
},
},
},
Vendor: &v1.Vendor{
Name: "testvendor",
},
},
expectedEvents: []*v1.SystemEventLogEntry{
{
Id: "1",
Timestamp: "2022-01-01",
Description: "Event 1",
Message: "Message 1",
},
{
Id: "2",
Timestamp: "2022-01-02",
Description: "Event 2",
Message: "Message 2",
},
},
expectedErr: nil,
},
{
name: "error creating system event log action",
ctx: context.Background(),
in: &v1.SystemEventLogRequest{
Authn: &v1.Authn{
Authn: &v1.Authn_DirectAuthn{
DirectAuthn: &v1.DirectAuthn{
Username: "testuser",
},
},
},
Vendor: &v1.Vendor{
Name: "testvendor",
},
},
expectedEvents: nil,
expectedErr: errors.New("error creating system event log action"),
},
{
name: "error getting system event log",
ctx: context.Background(),
in: &v1.SystemEventLogRequest{
Authn: &v1.Authn{
Authn: &v1.Authn_DirectAuthn{
DirectAuthn: &v1.DirectAuthn{
Username: "testuser",
},
},
},
Vendor: &v1.Vendor{
Name: "testvendor",
},
},
expectedEvents: nil,
expectedErr: errors.New("error getting system event log"),
},
}

for _, tc := range testCases {
testCase := tc
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()
diagnosticService := NewMockDiagnosticService()
diagnosticService.On("SystemEventLog", testCase.ctx, testCase.in).Return(&v1.SystemEventLogResponse{
Events: testCase.expectedEvents,
}, testCase.expectedErr)

response, err := diagnosticService.SystemEventLog(testCase.ctx, testCase.in)

if diff := cmp.Diff(testCase.expectedEvents, response.Events, cmpopts.IgnoreUnexported(v1.SystemEventLogEntry{})); diff != "" {
t.Errorf("Mismatch in events (-expected, +actual):\n%s", diff)
}

if diff := cmp.Diff(testCase.expectedErr, err, cmpopts.EquateErrors()); diff != "" {
t.Errorf("Mismatch in error (-expected, +actual):\n%s", diff)
}
})
}
}

type MockDiagnosticService struct {
mock.Mock
}

func NewMockDiagnosticService() *MockDiagnosticService {
return &MockDiagnosticService{}
}

func (m *MockDiagnosticService) Screenshot(ctx context.Context, in *v1.ScreenshotRequest) (*v1.ScreenshotResponse, error) {
args := m.Called(ctx, in)
resp, ok := args.Get(0).(*v1.ScreenshotResponse)
if !ok {
return nil, fmt.Errorf("unexpected type for ScreenshotResponse")
}
return resp, args.Error(1)
}

func (m *MockDiagnosticService) SystemEventLog(ctx context.Context, in *v1.SystemEventLogRequest) (*v1.SystemEventLogResponse, error) {
args := m.Called(ctx, in)
resp, ok := args.Get(0).(*v1.SystemEventLogResponse)
if !ok {
return nil, fmt.Errorf("unexpected type for SystemEventLogResponse")
}
return resp, args.Error(1)
}

func (m *MockDiagnosticService) SystemEventLogRaw(ctx context.Context, in *v1.SystemEventLogRawRequest) (*v1.SystemEventLogRawResponse, error) {
args := m.Called(ctx, in)
resp, ok := args.Get(0).(*v1.SystemEventLogRawResponse)
if !ok {
return nil, fmt.Errorf("unexpected type for SystemEventLogRawResponse")
}
return resp, args.Error(1)
}

0 comments on commit 658753b

Please sign in to comment.