Eun / go-hit

http integration test framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Steps added with `CombineSteps` get executed 2 times

Eun opened this issue · comments

func TestCombineSteps_DoubleExecution(t *testing.T) {
	s := EchoServer()
	defer s.Close()

	t.Run("send", func(t *testing.T) {
		calls := 0
		Test(
			t,
			Post(s.URL),
			CombineSteps(
				Send().Custom(func(hit Hit) {
					calls++
				}),
			),
		)
		require.Equal(t, 1, calls)
	})
	t.Run("expect", func(t *testing.T) {
		calls := 0
		Test(
			t,
			Post(s.URL),
			CombineSteps(
				Expect().Custom(func(hit Hit) {
					calls++
				}),
			),
		)
		require.Equal(t, 1, calls)
	})
	t.Run("other", func(t *testing.T) {
		calls := 0
		Test(
			t,
			Post(s.URL),
			CombineSteps(
				Custom(BeforeSendStep, func(hit Hit) {
					calls++
				}),
			),
		)
		require.Equal(t, 1, calls)
	})
}

Fixed in #4