digitalocean / doctl

The official command line interface for the DigitalOcean API.
https://docs.digitalocean.com/reference/doctl/
Apache License 2.0
3.26k stars 397 forks source link

doctl/do/mocks: regenerating mocks causes tests to fail for load balancers #218

Closed xmudrii closed 7 years ago

xmudrii commented 7 years ago

Using the regenmocks.sh script provided with doctl causes Load Balancer tests to fail. Offended functions have one thing in general, they're using String Slice as parameter for something.

List of offended functions:

All mentioned functions are part of load_balancers_test.go.

Go panic report for LB functions: ``` === RUN TestLoadBalancerCommand --- PASS: TestLoadBalancerCommand (0.00s) === RUN TestLoadBalancerGet --- PASS: TestLoadBalancerGet (0.00s) mock.go:368: ✅ Get(string) === RUN TestLoadBalancerGetNoID --- PASS: TestLoadBalancerGetNoID (0.00s) === RUN TestLoadBalancerList --- PASS: TestLoadBalancerList (0.00s) mock.go:368: ✅ List() === RUN TestLoadBalancerCreateWithInvalidDropletIDsArgs --- PASS: TestLoadBalancerCreateWithInvalidDropletIDsArgs (0.00s) === RUN TestLoadBalancerCreateWithMalformedForwardingRulesArgs --- PASS: TestLoadBalancerCreateWithMalformedForwardingRulesArgs (0.00s) === RUN TestLoadBalancerCreate --- PASS: TestLoadBalancerCreate (0.00s) mock.go:368: ✅ Create(*godo.LoadBalancerRequest) === RUN TestLoadBalancerUpdate --- PASS: TestLoadBalancerUpdate (0.00s) mock.go:368: ✅ Update(string,*godo.LoadBalancerRequest) === RUN TestLoadBalancerUpdateNoID --- PASS: TestLoadBalancerUpdateNoID (0.00s) === RUN TestLoadBalancerDelete --- PASS: TestLoadBalancerDelete (0.00s) mock.go:368: ✅ Delete(string) === RUN TestLoadBalancerDeleteNoID --- PASS: TestLoadBalancerDeleteNoID (0.00s) === RUN TestLoadBalancerAddDroplets --- FAIL: TestLoadBalancerAddDroplets (0.00s) panic: mock: Unexpected Method Call ----------------------------- AddDroplets(string,int,int) 0: "cde2c0d6-41e3-479e-ba60-ad971227232c" 1: 1 2: 23 The closest call I have is: AddDroplets(string,[]int) 0: "cde2c0d6-41e3-479e-ba60-ad971227232c" 1: []int{1, 23} [recovered] panic: mock: Unexpected Method Call ----------------------------- AddDroplets(string,int,int) 0: "cde2c0d6-41e3-479e-ba60-ad971227232c" 1: 1 2: 23 The closest call I have is: AddDroplets(string,[]int) 0: "cde2c0d6-41e3-479e-ba60-ad971227232c" 1: []int{1, 23} goroutine 132 [running]: testing.tRunner.func1(0xc4200620d0) /usr/local/go/src/testing/testing.go:622 +0x29d panic(0x96c500, 0xc420118bf0) /usr/local/go/src/runtime/panic.go:489 +0x2cf github.com/digitalocean/doctl/vendor/github.com/stretchr/testify/mock.(*Mock).Called(0xc4200811c0, 0xc4203b0450, 0x3, 0x3, 0xc42044a1a0, 0x2, 0x2) /home/marko/src/github.com/digitalocean/doctl/vendor/github.com/stretchr/testify/mock/mock.go:299 +0x668 github.com/digitalocean/doctl/do/mocks.(*LoadBalancersService).AddDroplets(0xc4200811c0, 0xa57149, 0x24, 0xc4201187c0, 0x2, 0x2, 0x0, 0x0) /home/marko/src/github.com/digitalocean/doctl/do/mocks/LoadBalancersService.go:23 +0x2c0 github.com/digitalocean/doctl/commands.RunLoadBalancerAddDroplets(0xc420098380, 0xa3f511, 0x4) /home/marko/src/github.com/digitalocean/doctl/commands/load_balancers.go:193 +0x1e7 github.com/digitalocean/doctl/commands.TestLoadBalancerAddDroplets.func1(0xc420098380, 0xc420080d80) /home/marko/src/github.com/digitalocean/doctl/commands/load_balancers_test.go:204 +0x378 github.com/digitalocean/doctl/commands.withTestClient(0xc4200620d0, 0xc420029788) /home/marko/src/github.com/digitalocean/doctl/commands/commands_test.go:206 +0x851 github.com/digitalocean/doctl/commands.TestLoadBalancerAddDroplets(0xc4200620d0) /home/marko/src/github.com/digitalocean/doctl/commands/load_balancers_test.go:206 +0x4f testing.tRunner(0xc4200620d0, 0xa67350) /usr/local/go/src/testing/testing.go:657 +0x96 created by testing.(*T).Run /usr/local/go/src/testing/testing.go:697 +0x2ca exit status 2 FAIL github.com/digitalocean/doctl/commands 0.035s ```

/cc @mauricio @viola @mchitten @hugocorbucci

mauricio commented 7 years ago

🎉