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

Included tests for internal/log/env #309

Merged
merged 3 commits into from
Jan 26, 2023

Conversation

nathannaveen
Copy link
Contributor

  • Included tests for internal/log/env
  • Included licenses for env.go and config.go

Signed-off-by: nathannaveen 42319948+nathannaveen@users.noreply.github.com

- Included tests for internal/log/env
- Included licenses for `env.go` and `config.go`

Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>
internal/log/env_test.go Show resolved Hide resolved
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, _ := tt.e.MarshalText() // this function never returns an error
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be a check that err is always nil so the assertion is checked.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I forgot about that when writing the test! I have added the error check err != nil.

t.Run(tt.name, func(t *testing.T) {
got, _ := tt.e.MarshalText() // this function never returns an error

if !reflect.DeepEqual(got, tt.want) {
Copy link
Contributor

Choose a reason for hiding this comment

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

bytes.Equal() a better choice than DeepEqual

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed it from reflect.DeepEqual() to bytes.Equal().

},
}
for _, tt := range tests {
t.Setenv(string(tt.text), tt.value)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this call does anything and probably should be removed, along with tt.value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed the t.Setenv() but I kept the tt.value because I added a check test.e.String() != test.value.

value: "dev",
},
}
for _, tt := range tests {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: test is a better than tt as tt is very similar to t

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed all the tt's to test.

nathannaveen and others added 2 commits January 25, 2023 09:43
Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>
@calebbrown calebbrown merged commit 238bc64 into ossf:main Jan 26, 2023
nathannaveen added a commit to nathannaveen/criticality_score that referenced this pull request Feb 9, 2023
* Included tests for internal/log/env

- Included tests for internal/log/env
- Included licenses for `env.go` and `config.go`

Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>

* Fixed based on code review

Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>

Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>
Co-authored-by: Caleb Brown <calebbrown@google.com>
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.

None yet

2 participants