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

feat: included tests for utils package #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

naveensrinivasan
Copy link
Contributor

  • included tests for utils package

Description

...

Related Issue

Fixes #

Relates to #

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Other (security config, docs update, etc)

Checklist before merging

- included tests for utils package

Signed-off-by: naveensrinivasan <[email protected]>
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := TemplateString(tt.args.templateMap, tt.args.s); got != tt.want {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of manually rolling the checks, in other tests we use the require function from testify which simpliies this logic

withs: map[string]string{"test-input": "value1"},
},
want: []types.Action{
{TaskReference: "test-task", With: map[string]string{"test-input": "value1"}},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be missing it, but where does the templating occur in this test (docs for reference)

t.Errorf("TemplateTaskActionsWithInputs() error = %v, wantErr %v", err, tt.wantErr)
return
}
if diff := cmp.Diff(tt.want, got, cmpopts.IgnoreFields(types.Action{}, "ZarfComponentAction")); diff != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another area where I think require is a bit cleaner with less code; maybe you could compare just a single field in the Action instead of doing the deep inspection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants