-
Notifications
You must be signed in to change notification settings - Fork 39
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
[controller] unwrap errors from m3admin #97
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,12 +22,18 @@ package controller | |
|
||
import ( | ||
"archive/zip" | ||
"errors" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/m3db/m3db-operator/pkg/m3admin" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
|
||
"github.com/golang/mock/gomock" | ||
"github.com/kubernetes/utils/pointer" | ||
pkgerrors "github.com/pkg/errors" | ||
"github.com/rakyll/statik/fs" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
@@ -55,6 +61,35 @@ func registerValidConfigMap() error { | |
return nil | ||
} | ||
|
||
func TestEnsurePlacement(t *testing.T) { | ||
cluster := getFixture("cluster-3-zones.yaml", t) | ||
deps := newTestDeps(t, &testOpts{ | ||
crdObjects: []runtime.Object{cluster}, | ||
}) | ||
k8sops, err := newFakeK8sops() | ||
require.NoError(t, err) | ||
|
||
placementMock := deps.placementClient | ||
defer deps.cleanup() | ||
|
||
controller := deps.newController() | ||
controller.k8sclient = k8sops | ||
|
||
placementMock.EXPECT().Get().Return(nil, pkgerrors.WithMessage(m3admin.ErrNotFound, "foo")) | ||
placementMock.EXPECT().Init(gomock.Any()) | ||
|
||
err = controller.EnsurePlacement(cluster) | ||
assert.NoError(t, err) | ||
|
||
placementMock.EXPECT().Get() | ||
err = controller.EnsurePlacement(cluster) | ||
assert.NoError(t, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as below |
||
|
||
placementMock.EXPECT().Get().Return(nil, errors.New("placement client not available")) | ||
err = controller.EnsurePlacement(cluster) | ||
assert.Error(t, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I worry about breaking convention with the style in the rest of our tests. Also personally I like having the error separate, if you're debugging a test it's easier to do something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay that's fair 👍 |
||
} | ||
|
||
func TestEnsureService_Base(t *testing.T) { | ||
cluster := getFixture("cluster-simple.yaml", t) | ||
k8sops, err := newFakeK8sops() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as below