Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unit tests for payload file #423

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions pkg/payload/load_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package payload

import (
"path/filepath"
"testing"

"github.com/stretchr/testify/require"
)

func TestLoad(t *testing.T) {
basePath := "../../test/commands/scan"
tests := []struct {
name string
path string
wantErr bool
}{
{
name: "Valid JSON File",
path: filepath.Join(basePath, "/tf-ec2/payload.json"),
wantErr: false,
},
{
name: "Valid YAML File",
path: filepath.Join(basePath, "/pod-no-latest/payload.yaml"),
wantErr: false,
},
{
name: "Not a YAML or a JSON File",
path: filepath.Join(basePath, "/dockerfile/out.txt"),
wantErr: true,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := Load(tt.path)
if tt.wantErr {
require.Error(t, err)
} else {
require.NoError(t, err)
}
})
}
}
Loading