Skip to content

Instantly share code, notes, and snippets.

@michaelgugino
Created May 10, 2019 15:30
Show Gist options
  • Select an option

  • Save michaelgugino/ea6f02f8bd8a4d44d5635de458b9ee75 to your computer and use it in GitHub Desktop.

Select an option

Save michaelgugino/ea6f02f8bd8a4d44d5635de458b9ee75 to your computer and use it in GitHub Desktop.
# put this in reconciler_test.go
func TestExists2(t *testing.T) {
scope, err := newLocalMachineScope()
if err != nil {
t.Fatalf("err: %v", err)
}
r := newReconciler(scope)
exists, err := r.instanceExists()
if err != nil {
t.Fatalf("err: %v", err)
}
if !exists {
t.Errorf("exists: %v", exists)
}
}
func newLocalMachineScope() (*machineScope, error) {
gclient, err := google.DefaultClient(context.TODO(), compute.ComputeScope)
if err != nil {
return nil, err
}
computeService, err := computeservice.NewComputeService(gclient)
if err != nil {
return nil, err
}
machineScope := machineScope{
machine: &v1beta1.Machine{
ObjectMeta: metav1.ObjectMeta{
Name: "notfound",
Namespace: "",
},
},
coreClient: controllerfake.NewFakeClient(),
providerSpec: &gcpv1beta1.GCPMachineProviderSpec{
Zone: "us-east1-c",
},
projectID: "notfound",
computeService: computeService,
}
return &machineScope, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment