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

Get rid of unchecked type assertions #646

Closed
jbarrick-mesosphere opened this issue Jul 25, 2019 · 1 comment · Fixed by #1245
Closed

Get rid of unchecked type assertions #646

jbarrick-mesosphere opened this issue Jul 25, 2019 · 1 comment · Fixed by #1245

Comments

@jbarrick-mesosphere
Copy link
Member

What happened:

The test harness has some unchecked type assertions that cause panics.

=== PAUSE TestHarnessRunIntegration/harness/create-or-update
panic: interface conversion: runtime.Object is *unstructured.Unstructured, not *v1alpha1.TestStep [recovered]
    panic: interface conversion: runtime.Object is *unstructured.Unstructured, not *v1alpha1.TestStep

goroutine 1036 [running]:
testing.tRunner.func1(0xc00051a300)
    /usr/local/Cellar/go/1.12.5/libexec/src/testing/testing.go:830 +0x392
panic(0x20e3ee0, 0xc0001b8cf0)
    /usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:522 +0x1b5
github.com/kudobuilder/kudo/pkg/test.(*Step).LoadYAML(0xc000124be0, 0xc000045180, 0x4e, 0x0, 0x0)
    /Users/gaston/mesosphere/kudo/pkg/test/step.go:373 +0xceb
github.com/kudobuilder/kudo/pkg/test.(*Case).LoadTestSteps(0xc000258230, 0xc000292730, 0x10)
    /Users/gaston/mesosphere/kudo/pkg/test/case.go:177 +0x326
github.com/kudobuilder/kudo/pkg/test.(*Harness).RunTests.func1(0xc00051a300)
    /Users/gaston/mesosphere/kudo/pkg/test/harness.go:252 +0x15e
testing.tRunner(0xc00051a300, 0xc0002fdbf0)
    /usr/local/Cellar/go/1.12.5/libexec/src/testing/testing.go:865 +0xc0
created by testing.(*T).Run
    /usr/local/Cellar/go/1.12.5/libexec/src/testing/testing.go:916 +0x35a
FAIL    github.com/kudobuilder/kudo/pkg/test    10.061s

Ideally we could add a linter that would detect all of these.

@porridge
Copy link
Member

porridge commented Jan 3, 2020

In the end I enabled reporting of the unchecked type assertions in #1245 usingerrcheck. It's not perfect but seems to catch at least the cases we had in our codebase.

@porridge porridge self-assigned this Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants