Skip to content

Commit

Permalink
Merge pull request #75 from Nopzen/main
Browse files Browse the repository at this point in the history
  • Loading branch information
ADustyOldMuffin committed Jan 25, 2023
2 parents 4758164 + 624be01 commit 2d1fa06
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 7 deletions.
1 change: 1 addition & 0 deletions OWNERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ guidelines and responsibilities for the steering committee and maintainers.
- Daniel Mangum <[email protected]> ([hasheddan](https://github.com/hasheddan))
- Khosrow Moossavi <[email protected]> ([khos2ow](https://github.com/khos2ow))
- Kim Schlesinger <[email protected]> ([kimschles](https://github.com/kimschles))
- Lars Krieger <[email protected]> ([nopzen](https://github.com/nopzen))
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/golang/mock v1.5.0
github.com/google/go-cmp v0.5.6
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.1
gopkg.in/alecthomas/kingpin.v2 v2.2.6
k8s.io/api v0.22.2
k8s.io/apimachinery v0.22.2
Expand Down Expand Up @@ -44,6 +45,7 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.11.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.26.0 // indirect
Expand All @@ -68,7 +70,7 @@ require (
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.22.2 // indirect
k8s.io/client-go v0.22.2 // indirect
k8s.io/component-base v0.22.2 // indirect
Expand Down
10 changes: 8 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -581,14 +581,19 @@ github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
Expand Down Expand Up @@ -1089,8 +1094,9 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20190905181640-827449938966/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
Expand Down
87 changes: 87 additions & 0 deletions pkg/clients/compute/droplet_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package compute

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/crossplane-contrib/provider-digitalocean/apis/compute/v1alpha1"

"github.com/digitalocean/godo"
)

var (
name = "mock-droplet"
region = "mock-region"
size = "mock-v1cpu-1gb"
image = "mock-ubuntu-20-04-x64"
sshKeys = []string{"mock-pub-key"}
backups = false
IPv6 = false
privateNetworking = false
monitoring = false
userData = "mock-user-data"
volumes = []string{"mock-volume"}
tags = []string{"mock-tag"}
VPCUUID = "mock-vpcuuid"
withDropletAgent = false
)

func TestGenerateDroplet(t *testing.T) {
type args struct {
name string
params v1alpha1.DropletParameters
create godo.DropletCreateRequest
}

tests := map[string]struct {
args args
want *godo.DropletCreateRequest
}{
"AllFilled": {
args: args{
name: name,
params: v1alpha1.DropletParameters{
Region: region,
Size: size,
Image: image,
SSHKeys: sshKeys,
Backups: &backups,
IPv6: &IPv6,
PrivateNetworking: &privateNetworking,
Monitoring: &monitoring,
UserData: &userData,
Volumes: volumes,
Tags: tags,
VPCUUID: &VPCUUID,
WithDropletAgent: &withDropletAgent,
},
create: godo.DropletCreateRequest{},
},
want: &godo.DropletCreateRequest{
Name: name,
Region: region,
Size: size,
Image: generateImage(image),
SSHKeys: generateSSHKeys(sshKeys),
Backups: backups,
IPv6: IPv6,
PrivateNetworking: privateNetworking,
Monitoring: monitoring,
UserData: userData,
Volumes: generateVolumes(volumes),
Tags: tags,
VPCUUID: VPCUUID,
WithDropletAgent: &withDropletAgent,
},
},
}

for tName, tc := range tests {
t.Run(tName, func(t *testing.T) {
GenerateDroplet(name, tc.args.params, &tc.args.create)

assert.Equal(t, tc.want, &tc.args.create)
})
}
}
6 changes: 2 additions & 4 deletions pkg/clients/kubernetes/containerregistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/digitalocean/godo"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"

"github.com/crossplane-contrib/provider-digitalocean/apis/kubernetes/v1alpha1"
)
Expand Down Expand Up @@ -86,9 +86,7 @@ func TestGenerateContainerRegistryObservation(t *testing.T) {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
r := GenerateContainerRegistryObservation(tc.args.registry, tc.args.subscription)
if diff := cmp.Diff(tc.want, r); diff != "" {
t.Errorf("GenerateContainerRegistryObservation(...): -want, +got:\n%s", diff)
}
assert.Equal(t, tc.want, r)
})
}
}

0 comments on commit 2d1fa06

Please sign in to comment.