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

go-concourse: split tests based on the client type used #800

Merged
merged 3 commits into from
Oct 4, 2024

Conversation

aliculPix4D
Copy link

@aliculPix4D aliculPix4D commented Oct 3, 2024

go-concourse: split tests based on the client type used

commit 1: connection fakes are unused. lets removed them and never generate them
commit 2: remove HTTP agent test from connection test suite
commit 3: create go-concourse/concourse/internal/http_agent_test.go and add back the test removed in commit 2

Test coverage percentage remained the same...

I like this PR because if connection client is deprecated, its even more important to keep the test for the HTTPAgent separate and clean... If they are mixed like there were before, its easy to remove the HTTPAgent test by accident when connection client really gets removed..

I didn't change a single line... stuff were just moved or removed...

"github.com/tedsuo/rata"
)

var _ = Describe("HTTPAgent Client", func() {

Choose a reason for hiding this comment

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

If I want to do the equivalent of go test -run Foo, is there a way with ginko? Would it use this name?

Copy link
Author

@aliculPix4D aliculPix4D Oct 3, 2024

Choose a reason for hiding this comment

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

I will check, but I am not invoking ginkgo directly... I am invoking go test...

so in internal_suite_test.go we have:

func TestInternal(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Internal Suite")
}

so the test name is actually: TestInternal and it contains actually all these 16 "specs".. So in my understanding you can't actually run only HTTPAgent Client without running also: ATC Connection.

I manage to run only these 16 specs by using:
go test -v ./go-concourse/... --run TestInternal

I didn't yet manage to achieve the same with ginkgo...
> ginkgo --focus "TestInternal" ./go-concourse/...

runs all... 16 specs from TestInternal and TestApi...

and furthermore, I for sure didn't manage to run a single test (or "spec" how they call it)

Update:

  • this seems to work...

go test -v -count=1 -short -coverprofile=.coverprofile.out ./go-concourse/... -ginkgo.focus "HTTPAgent"

Copy link
Author

@aliculPix4D aliculPix4D Oct 3, 2024

Choose a reason for hiding this comment

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

Oh finallly... I had wrong version of ginkgo installed... I was still at v1... while our tests require v2...

With v2 -focus flag works fine...
ginkgo -v -focus "HTTPAgent Client" -r ./go-concourse/...

See: onsi/ginkgo#1189

Choose a reason for hiding this comment

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

OK thanks. I think that it will be helpful to add a section to the README of the ci repo on how to run Ginko tests.
Now, if we can instead always invoke go test -run X, where X is a special string that matches ginko, we can write also that command for sure.

Copy link

@marco-m-pix4d marco-m-pix4d left a comment

Choose a reason for hiding this comment

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

Thanks.

@aliculPix4D aliculPix4D changed the base branch from master to release/7.11.x-pix4d October 4, 2024 14:07
@aliculPix4D aliculPix4D merged commit 0d5c826 into release/7.11.x-pix4d Oct 4, 2024
10 checks passed
@aliculPix4D aliculPix4D deleted the pci-3852-client-split-tests branch October 4, 2024 14:09
@aliculPix4D aliculPix4D restored the pci-3852-client-split-tests branch October 4, 2024 14:12
@aliculPix4D aliculPix4D deleted the pci-3852-client-split-tests branch October 4, 2024 14:27
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.

3 participants