gotests icon indicating copy to clipboard operation
gotests copied to clipboard

No need for "type args struct" if function takes a single-argument

Open ahmetb opened this issue 8 years ago • 1 comments

e.g.

func Test_clonePod(t *testing.T) {
	type args struct {
		pod *corev1.Pod
	}
	tests := []struct {
		name    string
		args    args
		want    *corev1.Pod
		wantErr bool
	}{
	    // TODO: Add test cases.
	}
	...
}

In the code above, instead of generating type args struct { ...}, it's sufficient to just specify args field in anonymous struct as *corev1.Pod and not generate an additional type. This should help create simpler and more readable tests.

ahmetb avatar Sep 11 '17 06:09 ahmetb

Sounds reasonable. Feel free to make a pull request.

cweill avatar Oct 10 '17 03:10 cweill