gotests icon indicating copy to clipboard operation
gotests copied to clipboard

Generated tests for main func have syntax err

Open huygn opened this issue 8 years ago • 3 comments

undefined: tt in tt.name.

func Test_main(t *testing.T) {
	tests := []struct {
		name string
	}{
	// TODO: Add test cases.
	}
	for range tests {
		t.Run(tt.name, func(t *testing.T) { // <-- tt is undefined
			main()
		})
	}
}

huygn avatar Nov 11 '16 03:11 huygn

I was bitten by this as well. Cause seems to be the template excluding loop index/value in the case of functions that take no arguments and return no values. function.tmpl, line 44

@cweill, can we just remove that check? If that's ok with you I will fix and send a PR.

adamdrake avatar May 13 '17 03:05 adamdrake

Hey yeah, sure thing. Send a PR and I'll approve.

cweill avatar May 13 '17 03:05 cweill

Thank you @cweill. Please review.

adamdrake avatar May 13 '17 03:05 adamdrake