diff --git a/internal/cmd/all/all.go b/internal/cmd/all/all.go index 83dc1743..08e11b91 100644 --- a/internal/cmd/all/all.go +++ b/internal/cmd/all/all.go @@ -15,7 +15,7 @@ func NewCommand(s state.State) *cobra.Command { DisableFlagsInUseLine: true, } cmd.AddCommand( - listCmd.CobraCommand(s), + ListCmd.CobraCommand(s), ) return cmd } diff --git a/internal/cmd/all/list.go b/internal/cmd/all/list.go index 1ec1a5df..37a9ac12 100644 --- a/internal/cmd/all/list.go +++ b/internal/cmd/all/list.go @@ -41,7 +41,7 @@ var allCmds = []base.ListCmd{ sshkey.ListCmd, } -var listCmd = base.Cmd{ +var ListCmd = base.Cmd{ BaseCobraCommand: func(client hcapi2.Client) *cobra.Command { var resources []string diff --git a/internal/cmd/all/list_test.go b/internal/cmd/all/list_test.go index a28453b2..f01eb4c0 100644 --- a/internal/cmd/all/list_test.go +++ b/internal/cmd/all/list_test.go @@ -1,4 +1,4 @@ -package all +package all_test import ( _ "embed" @@ -9,6 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/all" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -22,7 +23,7 @@ func TestListAll(t *testing.T) { time.Local = time.UTC - cmd := listCmd.CobraCommand(fx.State()) + cmd := all.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ServerClient.EXPECT(). @@ -246,7 +247,7 @@ func TestListAllPaidJSON(t *testing.T) { time.Local = time.UTC - cmd := listCmd.CobraCommand(fx.State()) + cmd := all.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ServerClient.EXPECT(). diff --git a/internal/cmd/certificate/create_test.go b/internal/cmd/certificate/create_test.go index b197e2c8..212d3aff 100644 --- a/internal/cmd/certificate/create_test.go +++ b/internal/cmd/certificate/create_test.go @@ -1,4 +1,4 @@ -package certificate +package certificate_test import ( _ "embed" @@ -8,6 +8,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/certificate" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -22,7 +23,7 @@ func TestCreateManaged(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := certificate.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.CertificateClient.EXPECT(). @@ -55,7 +56,7 @@ func TestCreateManagedJSON(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := certificate.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.CertificateClient.EXPECT(). @@ -104,7 +105,7 @@ func TestCreateUploaded(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := certificate.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.CertificateClient.EXPECT(). @@ -132,7 +133,7 @@ func TestCreateUploadedJSON(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := certificate.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.CertificateClient.EXPECT(). diff --git a/internal/cmd/certificate/delete_test.go b/internal/cmd/certificate/delete_test.go index 7d66a6bf..4e3cd6ec 100644 --- a/internal/cmd/certificate/delete_test.go +++ b/internal/cmd/certificate/delete_test.go @@ -1,4 +1,4 @@ -package certificate +package certificate_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/certificate" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDelete(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DeleteCmd.CobraCommand(fx.State()) + cmd := certificate.DeleteCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() cert := &hcloud.Certificate{ diff --git a/internal/cmd/certificate/describe_test.go b/internal/cmd/certificate/describe_test.go index 6e7b0bee..9015ee97 100644 --- a/internal/cmd/certificate/describe_test.go +++ b/internal/cmd/certificate/describe_test.go @@ -1,4 +1,4 @@ -package certificate +package certificate_test import ( "fmt" @@ -9,6 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/certificate" "github.com/hetznercloud/cli/internal/cmd/util" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" @@ -20,7 +21,7 @@ func TestDescribe(t *testing.T) { time.Local = time.UTC - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := certificate.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() cert := &hcloud.Certificate{ diff --git a/internal/cmd/certificate/labels_test.go b/internal/cmd/certificate/labels_test.go index d50cf046..493d02a9 100644 --- a/internal/cmd/certificate/labels_test.go +++ b/internal/cmd/certificate/labels_test.go @@ -1,4 +1,4 @@ -package certificate +package certificate_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/certificate" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestLabelAdd(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.AddCobraCommand(fx.State()) + cmd := certificate.LabelCmds.AddCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.CertificateClient.EXPECT(). @@ -39,7 +40,7 @@ func TestLabelRemove(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.RemoveCobraCommand(fx.State()) + cmd := certificate.LabelCmds.RemoveCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.CertificateClient.EXPECT(). diff --git a/internal/cmd/certificate/list_test.go b/internal/cmd/certificate/list_test.go index fb7fe2ed..f5cb5d93 100644 --- a/internal/cmd/certificate/list_test.go +++ b/internal/cmd/certificate/list_test.go @@ -1,4 +1,4 @@ -package certificate +package certificate_test import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/certificate" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -17,7 +18,7 @@ func TestList(t *testing.T) { time.Local = time.UTC - cmd := ListCmd.CobraCommand(fx.State()) + cmd := certificate.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.CertificateClient.EXPECT(). diff --git a/internal/cmd/certificate/update_test.go b/internal/cmd/certificate/update_test.go index 91a3928d..411dfc86 100644 --- a/internal/cmd/certificate/update_test.go +++ b/internal/cmd/certificate/update_test.go @@ -1,4 +1,4 @@ -package certificate +package certificate_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/certificate" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUpdateName(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateCmd.CobraCommand(fx.State()) + cmd := certificate.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.CertificateClient.EXPECT(). diff --git a/internal/cmd/datacenter/describe_test.go b/internal/cmd/datacenter/describe_test.go index 47cc0dc5..6d76c4eb 100644 --- a/internal/cmd/datacenter/describe_test.go +++ b/internal/cmd/datacenter/describe_test.go @@ -1,4 +1,4 @@ -package datacenter +package datacenter_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/datacenter" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDescribe(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := datacenter.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.DatacenterClient.EXPECT(). diff --git a/internal/cmd/datacenter/list_test.go b/internal/cmd/datacenter/list_test.go index ca8d202d..aa422924 100644 --- a/internal/cmd/datacenter/list_test.go +++ b/internal/cmd/datacenter/list_test.go @@ -1,4 +1,4 @@ -package datacenter +package datacenter_test import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/datacenter" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -17,7 +18,7 @@ func TestList(t *testing.T) { time.Local = time.UTC - cmd := ListCmd.CobraCommand(fx.State()) + cmd := datacenter.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.DatacenterClient.EXPECT(). diff --git a/internal/cmd/firewall/add_rule.go b/internal/cmd/firewall/add_rule.go index 736dd0e9..9fb468a5 100644 --- a/internal/cmd/firewall/add_rule.go +++ b/internal/cmd/firewall/add_rule.go @@ -87,7 +87,7 @@ var AddRuleCmd = base.Cmd{ case hcloud.FirewallRuleDirectionOut: rule.DestinationIPs = make([]net.IPNet, len(destinationIPs)) for i, ip := range destinationIPs { - n, err := validateFirewallIP(ip) + n, err := ValidateFirewallIP(ip) if err != nil { return fmt.Errorf("destination error on index %d: %s", i, err) } @@ -96,7 +96,7 @@ var AddRuleCmd = base.Cmd{ case hcloud.FirewallRuleDirectionIn: rule.SourceIPs = make([]net.IPNet, len(sourceIPs)) for i, ip := range sourceIPs { - n, err := validateFirewallIP(ip) + n, err := ValidateFirewallIP(ip) if err != nil { return fmt.Errorf("source ips error on index %d: %s", i, err) } diff --git a/internal/cmd/firewall/add_rule_test.go b/internal/cmd/firewall/add_rule_test.go index 10d3f256..002a29ea 100644 --- a/internal/cmd/firewall/add_rule_test.go +++ b/internal/cmd/firewall/add_rule_test.go @@ -1,4 +1,4 @@ -package firewall +package firewall_test import ( "net" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/firewall" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -15,19 +16,19 @@ func TestAddRule(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := AddRuleCmd.CobraCommand(fx.State()) + cmd := firewall.AddRuleCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - firewall := &hcloud.Firewall{ + fw := &hcloud.Firewall{ ID: 123, Name: "test", } fx.Client.FirewallClient.EXPECT(). Get(gomock.Any(), "test"). - Return(firewall, nil, nil) + Return(fw, nil, nil) fx.Client.FirewallClient.EXPECT(). - SetRules(gomock.Any(), firewall, hcloud.FirewallSetRulesOpts{ + SetRules(gomock.Any(), fw, hcloud.FirewallSetRulesOpts{ Rules: []hcloud.FirewallRule{{ Direction: hcloud.FirewallRuleDirectionIn, SourceIPs: []net.IPNet{{IP: net.IP{0, 0, 0, 0}, Mask: net.IPMask{0, 0, 0, 0}}}, diff --git a/internal/cmd/firewall/apply_to_resource_test.go b/internal/cmd/firewall/apply_to_resource_test.go index 67995c92..e5ed6491 100644 --- a/internal/cmd/firewall/apply_to_resource_test.go +++ b/internal/cmd/firewall/apply_to_resource_test.go @@ -1,4 +1,4 @@ -package firewall +package firewall_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/firewall" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,22 +15,22 @@ func TestApplyToServer(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := ApplyToResourceCmd.CobraCommand(fx.State()) + cmd := firewall.ApplyToResourceCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - firewall := &hcloud.Firewall{ + fw := &hcloud.Firewall{ ID: 123, Name: "test", } fx.Client.FirewallClient.EXPECT(). Get(gomock.Any(), "test"). - Return(firewall, nil, nil) + Return(fw, nil, nil) fx.Client.ServerClient.EXPECT(). Get(gomock.Any(), "my-server"). Return(&hcloud.Server{ID: 456}, nil, nil) fx.Client.FirewallClient.EXPECT(). - ApplyResources(gomock.Any(), firewall, []hcloud.FirewallResource{{ + ApplyResources(gomock.Any(), fw, []hcloud.FirewallResource{{ Type: hcloud.FirewallResourceTypeServer, Server: &hcloud.FirewallResourceServer{ ID: 456, @@ -52,19 +53,19 @@ func TestApplyToLabelSelector(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := ApplyToResourceCmd.CobraCommand(fx.State()) + cmd := firewall.ApplyToResourceCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - firewall := &hcloud.Firewall{ + fw := &hcloud.Firewall{ ID: 123, Name: "test", } fx.Client.FirewallClient.EXPECT(). Get(gomock.Any(), "test"). - Return(firewall, nil, nil) + Return(fw, nil, nil) fx.Client.FirewallClient.EXPECT(). - ApplyResources(gomock.Any(), firewall, []hcloud.FirewallResource{{ + ApplyResources(gomock.Any(), fw, []hcloud.FirewallResource{{ Type: hcloud.FirewallResourceTypeLabelSelector, LabelSelector: &hcloud.FirewallResourceLabelSelector{ Selector: "my-label", diff --git a/internal/cmd/firewall/create_test.go b/internal/cmd/firewall/create_test.go index 90e4068d..6d49aedf 100644 --- a/internal/cmd/firewall/create_test.go +++ b/internal/cmd/firewall/create_test.go @@ -1,4 +1,4 @@ -package firewall +package firewall_test import ( _ "embed" @@ -9,6 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/firewall" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -20,7 +21,7 @@ func TestCreate(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := firewall.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FirewallClient.EXPECT(). @@ -50,7 +51,7 @@ func TestCreateJSON(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := firewall.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FirewallClient.EXPECT(). diff --git a/internal/cmd/firewall/delete_rule.go b/internal/cmd/firewall/delete_rule.go index 59e5d66a..69577e49 100644 --- a/internal/cmd/firewall/delete_rule.go +++ b/internal/cmd/firewall/delete_rule.go @@ -86,7 +86,7 @@ var DeleteRuleCmd = base.Cmd{ case hcloud.FirewallRuleDirectionOut: rule.DestinationIPs = make([]net.IPNet, len(destinationIPs)) for i, ip := range destinationIPs { - n, err := validateFirewallIP(ip) + n, err := ValidateFirewallIP(ip) if err != nil { return fmt.Errorf("destination ips error on index %d: %s", i, err) } @@ -96,7 +96,7 @@ var DeleteRuleCmd = base.Cmd{ case hcloud.FirewallRuleDirectionIn: rule.SourceIPs = make([]net.IPNet, len(sourceIPs)) for i, ip := range sourceIPs { - n, err := validateFirewallIP(ip) + n, err := ValidateFirewallIP(ip) if err != nil { return fmt.Errorf("source ips error on index %d: %s", i, err) } diff --git a/internal/cmd/firewall/delete_rule_test.go b/internal/cmd/firewall/delete_rule_test.go index 47d8f9e2..2eae690b 100644 --- a/internal/cmd/firewall/delete_rule_test.go +++ b/internal/cmd/firewall/delete_rule_test.go @@ -1,4 +1,4 @@ -package firewall +package firewall_test import ( "net" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/firewall" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -15,10 +16,10 @@ func TestDeleteRule(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DeleteRuleCmd.CobraCommand(fx.State()) + cmd := firewall.DeleteRuleCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - firewall := &hcloud.Firewall{ + fw := &hcloud.Firewall{ ID: 123, Name: "test", Rules: []hcloud.FirewallRule{{ @@ -33,9 +34,9 @@ func TestDeleteRule(t *testing.T) { fx.Client.FirewallClient.EXPECT(). Get(gomock.Any(), "test"). - Return(firewall, nil, nil) + Return(fw, nil, nil) fx.Client.FirewallClient.EXPECT(). - SetRules(gomock.Any(), firewall, hcloud.FirewallSetRulesOpts{Rules: nil}). + SetRules(gomock.Any(), fw, hcloud.FirewallSetRulesOpts{Rules: nil}). Return([]*hcloud.Action{{ID: 123}, {ID: 321}}, nil, nil) fx.ActionWaiter.EXPECT(). WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 123}, {ID: 321}}). diff --git a/internal/cmd/firewall/delete_test.go b/internal/cmd/firewall/delete_test.go index ebc7c4da..be01d40c 100644 --- a/internal/cmd/firewall/delete_test.go +++ b/internal/cmd/firewall/delete_test.go @@ -1,4 +1,4 @@ -package firewall +package firewall_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/firewall" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,19 +15,19 @@ func TestDelete(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DeleteCmd.CobraCommand(fx.State()) + cmd := firewall.DeleteCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - firewall := &hcloud.Firewall{ + fw := &hcloud.Firewall{ ID: 123, Name: "test", } fx.Client.FirewallClient.EXPECT(). Get(gomock.Any(), "test"). - Return(firewall, nil, nil) + Return(fw, nil, nil) fx.Client.FirewallClient.EXPECT(). - Delete(gomock.Any(), firewall). + Delete(gomock.Any(), fw). Return(nil, nil) out, _, err := fx.Run(cmd, []string{"test"}) diff --git a/internal/cmd/firewall/describe_test.go b/internal/cmd/firewall/describe_test.go index aef61a0f..6b6e25c8 100644 --- a/internal/cmd/firewall/describe_test.go +++ b/internal/cmd/firewall/describe_test.go @@ -1,4 +1,4 @@ -package firewall +package firewall_test import ( "fmt" @@ -9,6 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/firewall" "github.com/hetznercloud/cli/internal/cmd/util" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" @@ -20,10 +21,10 @@ func TestDescribe(t *testing.T) { time.Local = time.UTC - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := firewall.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - firewall := &hcloud.Firewall{ + fw := &hcloud.Firewall{ ID: 123, Name: "test", Rules: []hcloud.FirewallRule{ @@ -50,7 +51,7 @@ func TestDescribe(t *testing.T) { fx.Client.FirewallClient.EXPECT(). Get(gomock.Any(), "test"). - Return(firewall, nil, nil) + Return(fw, nil, nil) fx.Client.ServerClient.EXPECT(). ServerName(int64(321)). Return("myServer") @@ -72,7 +73,7 @@ Applied To: - Type: server Server ID: 321 Server Name: myServer -`, util.Datetime(firewall.Created), humanize.Time(firewall.Created)) +`, util.Datetime(fw.Created), humanize.Time(fw.Created)) assert.NoError(t, err) assert.Equal(t, expOut, out) diff --git a/internal/cmd/firewall/labels_test.go b/internal/cmd/firewall/labels_test.go index 9e55df3f..d1294e41 100644 --- a/internal/cmd/firewall/labels_test.go +++ b/internal/cmd/firewall/labels_test.go @@ -1,4 +1,4 @@ -package firewall +package firewall_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/firewall" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestLabelAdd(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.AddCobraCommand(fx.State()) + cmd := firewall.LabelCmds.AddCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FirewallClient.EXPECT(). @@ -39,7 +40,7 @@ func TestLabelRemove(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.RemoveCobraCommand(fx.State()) + cmd := firewall.LabelCmds.RemoveCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FirewallClient.EXPECT(). diff --git a/internal/cmd/firewall/list_test.go b/internal/cmd/firewall/list_test.go index 640cf74b..7bb7ddb2 100644 --- a/internal/cmd/firewall/list_test.go +++ b/internal/cmd/firewall/list_test.go @@ -1,4 +1,4 @@ -package firewall +package firewall_test import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/firewall" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -17,7 +18,7 @@ func TestList(t *testing.T) { time.Local = time.UTC - cmd := ListCmd.CobraCommand(fx.State()) + cmd := firewall.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FirewallClient.EXPECT(). diff --git a/internal/cmd/firewall/remove_from_resource_test.go b/internal/cmd/firewall/remove_from_resource_test.go index 26825eea..92d99063 100644 --- a/internal/cmd/firewall/remove_from_resource_test.go +++ b/internal/cmd/firewall/remove_from_resource_test.go @@ -1,4 +1,4 @@ -package firewall +package firewall_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/firewall" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,22 +15,22 @@ func TestRemoveFromServer(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := RemoveFromResourceCmd.CobraCommand(fx.State()) + cmd := firewall.RemoveFromResourceCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - firewall := &hcloud.Firewall{ + fw := &hcloud.Firewall{ ID: 123, Name: "test", } fx.Client.FirewallClient.EXPECT(). Get(gomock.Any(), "test"). - Return(firewall, nil, nil) + Return(fw, nil, nil) fx.Client.ServerClient.EXPECT(). Get(gomock.Any(), "my-server"). Return(&hcloud.Server{ID: 456}, nil, nil) fx.Client.FirewallClient.EXPECT(). - RemoveResources(gomock.Any(), firewall, []hcloud.FirewallResource{{ + RemoveResources(gomock.Any(), fw, []hcloud.FirewallResource{{ Type: hcloud.FirewallResourceTypeServer, Server: &hcloud.FirewallResourceServer{ ID: 456, @@ -52,19 +53,19 @@ func TestRemoveFromLabelSelector(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := RemoveFromResourceCmd.CobraCommand(fx.State()) + cmd := firewall.RemoveFromResourceCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - firewall := &hcloud.Firewall{ + fw := &hcloud.Firewall{ ID: 123, Name: "test", } fx.Client.FirewallClient.EXPECT(). Get(gomock.Any(), "test"). - Return(firewall, nil, nil) + Return(fw, nil, nil) fx.Client.FirewallClient.EXPECT(). - RemoveResources(gomock.Any(), firewall, []hcloud.FirewallResource{{ + RemoveResources(gomock.Any(), fw, []hcloud.FirewallResource{{ Type: hcloud.FirewallResourceTypeLabelSelector, LabelSelector: &hcloud.FirewallResourceLabelSelector{ Selector: "my-label", diff --git a/internal/cmd/firewall/replace_rules_test.go b/internal/cmd/firewall/replace_rules_test.go index da53139e..2fcdfbfe 100644 --- a/internal/cmd/firewall/replace_rules_test.go +++ b/internal/cmd/firewall/replace_rules_test.go @@ -1,4 +1,4 @@ -package firewall +package firewall_test import ( "net" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/firewall" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -15,19 +16,19 @@ func TestReplaceRules(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := ReplaceRulesCmd.CobraCommand(fx.State()) + cmd := firewall.ReplaceRulesCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - firewall := &hcloud.Firewall{ + fw := &hcloud.Firewall{ ID: 123, Name: "test", } fx.Client.FirewallClient.EXPECT(). Get(gomock.Any(), "test"). - Return(firewall, nil, nil) + Return(fw, nil, nil) fx.Client.FirewallClient.EXPECT(). - SetRules(gomock.Any(), firewall, hcloud.FirewallSetRulesOpts{ + SetRules(gomock.Any(), fw, hcloud.FirewallSetRulesOpts{ Rules: []hcloud.FirewallRule{ { Direction: hcloud.FirewallRuleDirectionIn, diff --git a/internal/cmd/firewall/update_test.go b/internal/cmd/firewall/update_test.go index b71029a9..437d5b5f 100644 --- a/internal/cmd/firewall/update_test.go +++ b/internal/cmd/firewall/update_test.go @@ -1,4 +1,4 @@ -package firewall +package firewall_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/firewall" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUpdateName(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateCmd.CobraCommand(fx.State()) + cmd := firewall.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FirewallClient.EXPECT(). diff --git a/internal/cmd/firewall/validation.go b/internal/cmd/firewall/validation.go index 1a7bb15e..0ae7b73f 100644 --- a/internal/cmd/firewall/validation.go +++ b/internal/cmd/firewall/validation.go @@ -5,7 +5,7 @@ import ( "net" ) -func validateFirewallIP(ip string) (*net.IPNet, error) { +func ValidateFirewallIP(ip string) (*net.IPNet, error) { i, n, err := net.ParseCIDR(ip) if err != nil { return nil, fmt.Errorf("%s", err) diff --git a/internal/cmd/firewall/validation_test.go b/internal/cmd/firewall/validation_test.go index a1393cf1..18ec5750 100644 --- a/internal/cmd/firewall/validation_test.go +++ b/internal/cmd/firewall/validation_test.go @@ -1,10 +1,12 @@ -package firewall +package firewall_test import ( "fmt" "testing" "github.com/stretchr/testify/assert" + + "github.com/hetznercloud/cli/internal/cmd/firewall" ) func TestValidateFirewallIP(t *testing.T) { @@ -49,7 +51,7 @@ func TestValidateFirewallIP(t *testing.T) { } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - net, err := validateFirewallIP(test.ip) + net, err := firewall.ValidateFirewallIP(test.ip) if test.err != nil { assert.Equal(t, err, test.err) diff --git a/internal/cmd/floatingip/assign_test.go b/internal/cmd/floatingip/assign_test.go index 8f6871b4..a20baecb 100644 --- a/internal/cmd/floatingip/assign_test.go +++ b/internal/cmd/floatingip/assign_test.go @@ -1,4 +1,4 @@ -package floatingip +package floatingip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/floatingip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestAssign(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := AssignCmd.CobraCommand(fx.State()) + cmd := floatingip.AssignCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FloatingIPClient.EXPECT(). diff --git a/internal/cmd/floatingip/create_test.go b/internal/cmd/floatingip/create_test.go index 608d3bf0..330d7b8d 100644 --- a/internal/cmd/floatingip/create_test.go +++ b/internal/cmd/floatingip/create_test.go @@ -1,4 +1,4 @@ -package floatingip +package floatingip_test import ( _ "embed" @@ -8,6 +8,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/floatingip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -19,7 +20,7 @@ func TestCreate(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := floatingip.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FloatingIPClient.EXPECT(). @@ -54,7 +55,7 @@ func TestCreateJSON(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := floatingip.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FloatingIPClient.EXPECT(). @@ -90,7 +91,7 @@ func TestCreateProtection(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := floatingip.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() floatingIp := &hcloud.FloatingIP{ diff --git a/internal/cmd/floatingip/delete_test.go b/internal/cmd/floatingip/delete_test.go index 6e3bfcce..585ad49e 100644 --- a/internal/cmd/floatingip/delete_test.go +++ b/internal/cmd/floatingip/delete_test.go @@ -1,4 +1,4 @@ -package floatingip +package floatingip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/floatingip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDelete(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DeleteCmd.CobraCommand(fx.State()) + cmd := floatingip.DeleteCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() floatingIP := &hcloud.FloatingIP{ diff --git a/internal/cmd/floatingip/describe_test.go b/internal/cmd/floatingip/describe_test.go index 2dae550f..afe48746 100644 --- a/internal/cmd/floatingip/describe_test.go +++ b/internal/cmd/floatingip/describe_test.go @@ -1,4 +1,4 @@ -package floatingip +package floatingip_test import ( "fmt" @@ -10,6 +10,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/floatingip" "github.com/hetznercloud/cli/internal/cmd/util" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" @@ -21,7 +22,7 @@ func TestDescribe(t *testing.T) { time.Local = time.UTC - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := floatingip.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() floatingIP := &hcloud.FloatingIP{ diff --git a/internal/cmd/floatingip/disable_protection_test.go b/internal/cmd/floatingip/disable_protection_test.go index 82a7ee25..4cfd50ef 100644 --- a/internal/cmd/floatingip/disable_protection_test.go +++ b/internal/cmd/floatingip/disable_protection_test.go @@ -1,4 +1,4 @@ -package floatingip +package floatingip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/floatingip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDisableProtection(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DisableProtectionCmd.CobraCommand(fx.State()) + cmd := floatingip.DisableProtectionCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FloatingIPClient.EXPECT(). diff --git a/internal/cmd/floatingip/enable_protection_test.go b/internal/cmd/floatingip/enable_protection_test.go index c0de258b..c5424938 100644 --- a/internal/cmd/floatingip/enable_protection_test.go +++ b/internal/cmd/floatingip/enable_protection_test.go @@ -1,4 +1,4 @@ -package floatingip +package floatingip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/floatingip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestEnableProtection(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := EnableProtectionCmd.CobraCommand(fx.State()) + cmd := floatingip.EnableProtectionCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FloatingIPClient.EXPECT(). diff --git a/internal/cmd/floatingip/labels_test.go b/internal/cmd/floatingip/labels_test.go index 1fc1a980..122971ec 100644 --- a/internal/cmd/floatingip/labels_test.go +++ b/internal/cmd/floatingip/labels_test.go @@ -1,4 +1,4 @@ -package floatingip +package floatingip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/floatingip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestLabelAdd(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.AddCobraCommand(fx.State()) + cmd := floatingip.LabelCmds.AddCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FloatingIPClient.EXPECT(). @@ -39,7 +40,7 @@ func TestLabelRemove(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.RemoveCobraCommand(fx.State()) + cmd := floatingip.LabelCmds.RemoveCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FloatingIPClient.EXPECT(). diff --git a/internal/cmd/floatingip/list_test.go b/internal/cmd/floatingip/list_test.go index 723a2d2a..36c21be7 100644 --- a/internal/cmd/floatingip/list_test.go +++ b/internal/cmd/floatingip/list_test.go @@ -1,4 +1,4 @@ -package floatingip +package floatingip_test import ( "net" @@ -8,6 +8,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/floatingip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -18,7 +19,7 @@ func TestList(t *testing.T) { time.Local = time.UTC - cmd := ListCmd.CobraCommand(fx.State()) + cmd := floatingip.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FloatingIPClient.EXPECT(). diff --git a/internal/cmd/floatingip/set_rdns_test.go b/internal/cmd/floatingip/set_rdns_test.go index 7ffec61b..3e14285a 100644 --- a/internal/cmd/floatingip/set_rdns_test.go +++ b/internal/cmd/floatingip/set_rdns_test.go @@ -1,4 +1,4 @@ -package floatingip +package floatingip_test import ( "net" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/floatingip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -15,7 +16,7 @@ func TestSetRDNS(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := SetRDNSCmd.CobraCommand(fx.State()) + cmd := floatingip.SetRDNSCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() floatingIP := &hcloud.FloatingIP{ diff --git a/internal/cmd/floatingip/unassign_test.go b/internal/cmd/floatingip/unassign_test.go index d3f07355..ba63ac17 100644 --- a/internal/cmd/floatingip/unassign_test.go +++ b/internal/cmd/floatingip/unassign_test.go @@ -1,4 +1,4 @@ -package floatingip +package floatingip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/floatingip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUnassign(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UnassignCmd.CobraCommand(fx.State()) + cmd := floatingip.UnassignCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FloatingIPClient.EXPECT(). diff --git a/internal/cmd/floatingip/update_test.go b/internal/cmd/floatingip/update_test.go index 9f7c3eea..944dec79 100644 --- a/internal/cmd/floatingip/update_test.go +++ b/internal/cmd/floatingip/update_test.go @@ -1,4 +1,4 @@ -package floatingip +package floatingip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/floatingip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUpdateName(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateCmd.CobraCommand(fx.State()) + cmd := floatingip.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FloatingIPClient.EXPECT(). @@ -37,7 +38,7 @@ func TestUpdateDescription(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateCmd.CobraCommand(fx.State()) + cmd := floatingip.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.FloatingIPClient.EXPECT(). diff --git a/internal/cmd/image/delete_test.go b/internal/cmd/image/delete_test.go index 62af9a30..48c1ab7a 100644 --- a/internal/cmd/image/delete_test.go +++ b/internal/cmd/image/delete_test.go @@ -1,4 +1,4 @@ -package image +package image_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/image" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,19 +15,19 @@ func TestDelete(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DeleteCmd.CobraCommand(fx.State()) + cmd := image.DeleteCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - image := &hcloud.Image{ + img := &hcloud.Image{ ID: 123, Name: "test", } fx.Client.ImageClient.EXPECT(). Get(gomock.Any(), "test"). - Return(image, nil, nil) + Return(img, nil, nil) fx.Client.ImageClient.EXPECT(). - Delete(gomock.Any(), image). + Delete(gomock.Any(), img). Return(nil, nil) out, _, err := fx.Run(cmd, []string{"test"}) diff --git a/internal/cmd/image/describe_test.go b/internal/cmd/image/describe_test.go index 2e41d9d1..2b49a25e 100644 --- a/internal/cmd/image/describe_test.go +++ b/internal/cmd/image/describe_test.go @@ -1,4 +1,4 @@ -package image +package image_test import ( "fmt" @@ -9,6 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/image" "github.com/hetznercloud/cli/internal/cmd/util" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" @@ -20,7 +21,7 @@ func TestDescribe(t *testing.T) { time.Local = time.UTC - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := image.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() img := &hcloud.Image{ diff --git a/internal/cmd/image/disable_protection_test.go b/internal/cmd/image/disable_protection_test.go index 86e93efc..ba9dbffd 100644 --- a/internal/cmd/image/disable_protection_test.go +++ b/internal/cmd/image/disable_protection_test.go @@ -1,4 +1,4 @@ -package image +package image_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/image" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDisableProtection(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DisableProtectionCmd.CobraCommand(fx.State()) + cmd := image.DisableProtectionCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ImageClient.EXPECT(). diff --git a/internal/cmd/image/enable_protection_test.go b/internal/cmd/image/enable_protection_test.go index d084e176..ca01e7c3 100644 --- a/internal/cmd/image/enable_protection_test.go +++ b/internal/cmd/image/enable_protection_test.go @@ -1,4 +1,4 @@ -package image +package image_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/image" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestEnableProtection(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := EnableProtectionCmd.CobraCommand(fx.State()) + cmd := image.EnableProtectionCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ImageClient.EXPECT(). diff --git a/internal/cmd/image/labels_test.go b/internal/cmd/image/labels_test.go index d7c70c70..0684ca04 100644 --- a/internal/cmd/image/labels_test.go +++ b/internal/cmd/image/labels_test.go @@ -1,4 +1,4 @@ -package image +package image_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/image" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestLabelAdd(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.AddCobraCommand(fx.State()) + cmd := image.LabelCmds.AddCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ImageClient.EXPECT(). @@ -39,7 +40,7 @@ func TestLabelRemove(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.RemoveCobraCommand(fx.State()) + cmd := image.LabelCmds.RemoveCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ImageClient.EXPECT(). diff --git a/internal/cmd/image/list_test.go b/internal/cmd/image/list_test.go index b3b97f1b..6e96c8cb 100644 --- a/internal/cmd/image/list_test.go +++ b/internal/cmd/image/list_test.go @@ -1,4 +1,4 @@ -package image +package image_test import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/image" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -17,7 +18,7 @@ func TestList(t *testing.T) { time.Local = time.UTC - cmd := ListCmd.CobraCommand(fx.State()) + cmd := image.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ImageClient.EXPECT(). diff --git a/internal/cmd/image/update_test.go b/internal/cmd/image/update_test.go index 24573105..1447024e 100644 --- a/internal/cmd/image/update_test.go +++ b/internal/cmd/image/update_test.go @@ -1,4 +1,4 @@ -package image +package image_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/image" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUpdateDescription(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateCmd.CobraCommand(fx.State()) + cmd := image.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ImageClient.EXPECT(). @@ -37,7 +38,7 @@ func TestUpdateType(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateCmd.CobraCommand(fx.State()) + cmd := image.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ImageClient.EXPECT(). diff --git a/internal/cmd/iso/describe_test.go b/internal/cmd/iso/describe_test.go index 0b5ac71e..f33d6123 100644 --- a/internal/cmd/iso/describe_test.go +++ b/internal/cmd/iso/describe_test.go @@ -1,4 +1,4 @@ -package iso +package iso_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/iso" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDescribe(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := iso.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ISOClient.EXPECT(). diff --git a/internal/cmd/iso/list_test.go b/internal/cmd/iso/list_test.go index fa0c400d..c2bc0504 100644 --- a/internal/cmd/iso/list_test.go +++ b/internal/cmd/iso/list_test.go @@ -1,4 +1,4 @@ -package iso +package iso_test import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/iso" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -17,7 +18,7 @@ func TestList(t *testing.T) { time.Local = time.UTC - cmd := ListCmd.CobraCommand(fx.State()) + cmd := iso.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ISOClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/add_service_test.go b/internal/cmd/loadbalancer/add_service_test.go index 4f281ce8..0924efaf 100644 --- a/internal/cmd/loadbalancer/add_service_test.go +++ b/internal/cmd/loadbalancer/add_service_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestAddService(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := AddServiceCmd.CobraCommand(fx.State()) + cmd := loadbalancer.AddServiceCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/add_target_test.go b/internal/cmd/loadbalancer/add_target_test.go index 50b69d92..14d0ad87 100644 --- a/internal/cmd/loadbalancer/add_target_test.go +++ b/internal/cmd/loadbalancer/add_target_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "net" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -15,7 +16,7 @@ func TestAddTargetServer(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := AddTargetCmd.CobraCommand(fx.State()) + cmd := loadbalancer.AddTargetCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). @@ -46,7 +47,7 @@ func TestAddTargetLabelSelector(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := AddTargetCmd.CobraCommand(fx.State()) + cmd := loadbalancer.AddTargetCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). @@ -74,7 +75,7 @@ func TestAddTargetIP(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := AddTargetCmd.CobraCommand(fx.State()) + cmd := loadbalancer.AddTargetCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/attach_to_network_test.go b/internal/cmd/loadbalancer/attach_to_network_test.go index e9a7a90f..c26d32dd 100644 --- a/internal/cmd/loadbalancer/attach_to_network_test.go +++ b/internal/cmd/loadbalancer/attach_to_network_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestAttachToNetwork(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := AttachToNetworkCmd.CobraCommand(fx.State()) + cmd := loadbalancer.AttachToNetworkCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/change_algorithm_test.go b/internal/cmd/loadbalancer/change_algorithm_test.go index 4ba64ca5..5499ced1 100644 --- a/internal/cmd/loadbalancer/change_algorithm_test.go +++ b/internal/cmd/loadbalancer/change_algorithm_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestChangeAlgorithm(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := ChangeAlgorithmCmd.CobraCommand(fx.State()) + cmd := loadbalancer.ChangeAlgorithmCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/change_type_test.go b/internal/cmd/loadbalancer/change_type_test.go index a0c8f550..e1a0b669 100644 --- a/internal/cmd/loadbalancer/change_type_test.go +++ b/internal/cmd/loadbalancer/change_type_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestChangeType(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := ChangeTypeCmd.CobraCommand(fx.State()) + cmd := loadbalancer.ChangeTypeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() lbType := &hcloud.LoadBalancerType{ID: 321, Name: "lb21"} diff --git a/internal/cmd/loadbalancer/create_test.go b/internal/cmd/loadbalancer/create_test.go index 91c424f2..0fa8a220 100644 --- a/internal/cmd/loadbalancer/create_test.go +++ b/internal/cmd/loadbalancer/create_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( _ "embed" @@ -9,6 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -20,7 +21,7 @@ func TestCreate(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := loadbalancer.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). @@ -64,7 +65,7 @@ func TestCreateJSON(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := loadbalancer.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() lb := &hcloud.LoadBalancer{ @@ -114,7 +115,7 @@ func TestCreateProtection(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := loadbalancer.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() loadBalancer := &hcloud.LoadBalancer{ diff --git a/internal/cmd/loadbalancer/delete_service_test.go b/internal/cmd/loadbalancer/delete_service_test.go index 9f075a9e..e26f151f 100644 --- a/internal/cmd/loadbalancer/delete_service_test.go +++ b/internal/cmd/loadbalancer/delete_service_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDeleteService(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DeleteServiceCmd.CobraCommand(fx.State()) + cmd := loadbalancer.DeleteServiceCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/delete_test.go b/internal/cmd/loadbalancer/delete_test.go index 3088652f..36de7cd1 100644 --- a/internal/cmd/loadbalancer/delete_test.go +++ b/internal/cmd/loadbalancer/delete_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDelete(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DeleteCmd.CobraCommand(fx.State()) + cmd := loadbalancer.DeleteCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() loadBalancer := &hcloud.LoadBalancer{ diff --git a/internal/cmd/loadbalancer/describe_test.go b/internal/cmd/loadbalancer/describe_test.go index d4ac947e..d1e3bdd8 100644 --- a/internal/cmd/loadbalancer/describe_test.go +++ b/internal/cmd/loadbalancer/describe_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "fmt" @@ -10,6 +10,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/cmd/util" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" @@ -21,7 +22,7 @@ func TestDescribe(t *testing.T) { time.Local = time.UTC - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := loadbalancer.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() lb := &hcloud.LoadBalancer{ diff --git a/internal/cmd/loadbalancer/detach_from_network_test.go b/internal/cmd/loadbalancer/detach_from_network_test.go index 48483168..fd4c8142 100644 --- a/internal/cmd/loadbalancer/detach_from_network_test.go +++ b/internal/cmd/loadbalancer/detach_from_network_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDetachFromNetwork(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DetachFromNetworkCmd.CobraCommand(fx.State()) + cmd := loadbalancer.DetachFromNetworkCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/disable_protection_test.go b/internal/cmd/loadbalancer/disable_protection_test.go index b2591aa9..e7d829fd 100644 --- a/internal/cmd/loadbalancer/disable_protection_test.go +++ b/internal/cmd/loadbalancer/disable_protection_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDisableProtection(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DisableProtectionCmd.CobraCommand(fx.State()) + cmd := loadbalancer.DisableProtectionCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/disable_public_interface_test.go b/internal/cmd/loadbalancer/disable_public_interface_test.go index 22bcd699..2587f0f7 100644 --- a/internal/cmd/loadbalancer/disable_public_interface_test.go +++ b/internal/cmd/loadbalancer/disable_public_interface_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDisablePublicInterface(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DisablePublicInterfaceCmd.CobraCommand(fx.State()) + cmd := loadbalancer.DisablePublicInterfaceCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/enable_protection_test.go b/internal/cmd/loadbalancer/enable_protection_test.go index 62e0dc6b..e4dd2177 100644 --- a/internal/cmd/loadbalancer/enable_protection_test.go +++ b/internal/cmd/loadbalancer/enable_protection_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestEnableProtection(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := EnableProtectionCmd.CobraCommand(fx.State()) + cmd := loadbalancer.EnableProtectionCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/enable_public_interface_test.go b/internal/cmd/loadbalancer/enable_public_interface_test.go index 254aa352..43033f7e 100644 --- a/internal/cmd/loadbalancer/enable_public_interface_test.go +++ b/internal/cmd/loadbalancer/enable_public_interface_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestEnablePublicInterface(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := EnablePublicInterfaceCmd.CobraCommand(fx.State()) + cmd := loadbalancer.EnablePublicInterfaceCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/labels_test.go b/internal/cmd/loadbalancer/labels_test.go index 9ea8dc80..9a72d32b 100644 --- a/internal/cmd/loadbalancer/labels_test.go +++ b/internal/cmd/loadbalancer/labels_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestLabelAdd(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.AddCobraCommand(fx.State()) + cmd := loadbalancer.LabelCmds.AddCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). @@ -39,7 +40,7 @@ func TestLabelRemove(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.RemoveCobraCommand(fx.State()) + cmd := loadbalancer.LabelCmds.RemoveCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/list.go b/internal/cmd/loadbalancer/list.go index 226d8a6d..3039143a 100644 --- a/internal/cmd/loadbalancer/list.go +++ b/internal/cmd/loadbalancer/list.go @@ -78,7 +78,7 @@ var ListCmd = base.ListCmd{ })). AddFieldFn("health", output.FieldFn(func(obj interface{}) string { loadBalancer := obj.(*hcloud.LoadBalancer) - return loadBalancerHealth(loadBalancer) + return Health(loadBalancer) })) }, @@ -92,7 +92,7 @@ var ListCmd = base.ListCmd{ }, } -func loadBalancerHealth(l *hcloud.LoadBalancer) string { +func Health(l *hcloud.LoadBalancer) string { healthyCount := 0 unhealthyCount := 0 unknownCount := 0 diff --git a/internal/cmd/loadbalancer/list_test.go b/internal/cmd/loadbalancer/list_test.go index 40a974ad..e647ac7f 100644 --- a/internal/cmd/loadbalancer/list_test.go +++ b/internal/cmd/loadbalancer/list_test.go @@ -1,10 +1,11 @@ -package loadbalancer +package loadbalancer_test import ( "testing" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -197,7 +198,7 @@ func TestLoadBalancerHealth(t *testing.T) { } for _, test := range tests { - res := loadBalancerHealth(test.lb) + res := loadbalancer.Health(test.lb) assert.Equal(t, test.expected, res, test.name) } } diff --git a/internal/cmd/loadbalancer/metrics_test.go b/internal/cmd/loadbalancer/metrics_test.go index 21c5c880..a8f1ad13 100644 --- a/internal/cmd/loadbalancer/metrics_test.go +++ b/internal/cmd/loadbalancer/metrics_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -15,7 +16,7 @@ func TestMetrics(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := MetricsCmd.CobraCommand(fx.State()) + cmd := loadbalancer.MetricsCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() start := time.Date(2022, 11, 1, 0, 0, 0, 0, time.UTC) diff --git a/internal/cmd/loadbalancer/remove_target_test.go b/internal/cmd/loadbalancer/remove_target_test.go index 2a832650..bd08a8be 100644 --- a/internal/cmd/loadbalancer/remove_target_test.go +++ b/internal/cmd/loadbalancer/remove_target_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "net" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -15,7 +16,7 @@ func TestRemoveTargetServer(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := RemoveTargetCmd.CobraCommand(fx.State()) + cmd := loadbalancer.RemoveTargetCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). @@ -43,7 +44,7 @@ func TestRemoveTargetLabelSelector(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := RemoveTargetCmd.CobraCommand(fx.State()) + cmd := loadbalancer.RemoveTargetCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). @@ -68,7 +69,7 @@ func TestRemoveTargetIP(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := RemoveTargetCmd.CobraCommand(fx.State()) + cmd := loadbalancer.RemoveTargetCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/set_rdns_test.go b/internal/cmd/loadbalancer/set_rdns_test.go index 3fbf1761..6b8a91fd 100644 --- a/internal/cmd/loadbalancer/set_rdns_test.go +++ b/internal/cmd/loadbalancer/set_rdns_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "net" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -15,7 +16,7 @@ func TestSetRDNS(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := SetRDNSCmd.CobraCommand(fx.State()) + cmd := loadbalancer.SetRDNSCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() loadBalancer := &hcloud.LoadBalancer{ diff --git a/internal/cmd/loadbalancer/update_service_test.go b/internal/cmd/loadbalancer/update_service_test.go index 544491c4..246ff2cf 100644 --- a/internal/cmd/loadbalancer/update_service_test.go +++ b/internal/cmd/loadbalancer/update_service_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -15,7 +16,7 @@ func TestUpdateService(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateServiceCmd.CobraCommand(fx.State()) + cmd := loadbalancer.UpdateServiceCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancer/update_test.go b/internal/cmd/loadbalancer/update_test.go index cd1d6b2b..f597d110 100644 --- a/internal/cmd/loadbalancer/update_test.go +++ b/internal/cmd/loadbalancer/update_test.go @@ -1,4 +1,4 @@ -package loadbalancer +package loadbalancer_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancer" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUpdateName(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateCmd.CobraCommand(fx.State()) + cmd := loadbalancer.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerClient.EXPECT(). diff --git a/internal/cmd/loadbalancertype/describe_test.go b/internal/cmd/loadbalancertype/describe_test.go index 460bfff0..1565a071 100644 --- a/internal/cmd/loadbalancertype/describe_test.go +++ b/internal/cmd/loadbalancertype/describe_test.go @@ -1,4 +1,4 @@ -package loadbalancertype +package loadbalancertype_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancertype" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDescribe(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := loadbalancertype.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerTypeClient.EXPECT(). diff --git a/internal/cmd/loadbalancertype/list_test.go b/internal/cmd/loadbalancertype/list_test.go index 5c8c7c66..c89ac245 100644 --- a/internal/cmd/loadbalancertype/list_test.go +++ b/internal/cmd/loadbalancertype/list_test.go @@ -1,4 +1,4 @@ -package loadbalancertype +package loadbalancertype_test import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/loadbalancertype" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -17,7 +18,7 @@ func TestList(t *testing.T) { time.Local = time.UTC - cmd := ListCmd.CobraCommand(fx.State()) + cmd := loadbalancertype.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LoadBalancerTypeClient.EXPECT(). diff --git a/internal/cmd/location/list_test.go b/internal/cmd/location/list_test.go index 117f21b0..d9052527 100644 --- a/internal/cmd/location/list_test.go +++ b/internal/cmd/location/list_test.go @@ -1,4 +1,4 @@ -package location +package location_test import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/location" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -17,7 +18,7 @@ func TestList(t *testing.T) { time.Local = time.UTC - cmd := ListCmd.CobraCommand(fx.State()) + cmd := location.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.LocationClient.EXPECT(). diff --git a/internal/cmd/network/create_test.go b/internal/cmd/network/create_test.go index e714fc66..e260ae9a 100644 --- a/internal/cmd/network/create_test.go +++ b/internal/cmd/network/create_test.go @@ -1,4 +1,4 @@ -package network +package network_test import ( _ "embed" @@ -9,6 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/network" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -20,7 +21,7 @@ func TestCreate(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := network.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() _, ipRange, _ := net.ParseCIDR("10.0.0.0/24") @@ -50,7 +51,7 @@ func TestCreateJSON(t *testing.T) { time.Local = time.UTC - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := network.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() _, ipRange, _ := net.ParseCIDR("10.0.0.0/24") @@ -84,11 +85,11 @@ func TestCreateProtection(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := network.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() _, ipRange, _ := net.ParseCIDR("10.0.0.0/24") - network := &hcloud.Network{ + n := &hcloud.Network{ ID: 123, Name: "myNetwork", IPRange: ipRange, @@ -100,9 +101,9 @@ func TestCreateProtection(t *testing.T) { IPRange: ipRange, Labels: make(map[string]string), }). - Return(network, nil, nil) + Return(n, nil, nil) fx.Client.NetworkClient.EXPECT(). - ChangeProtection(gomock.Any(), network, hcloud.NetworkChangeProtectionOpts{ + ChangeProtection(gomock.Any(), n, hcloud.NetworkChangeProtectionOpts{ Delete: hcloud.Ptr(true), }). Return(&hcloud.Action{ID: 123}, nil, nil) diff --git a/internal/cmd/network/delete_test.go b/internal/cmd/network/delete_test.go index bd0bf729..2dec6404 100644 --- a/internal/cmd/network/delete_test.go +++ b/internal/cmd/network/delete_test.go @@ -1,4 +1,4 @@ -package network +package network_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/network" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,19 +15,19 @@ func TestDelete(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DeleteCmd.CobraCommand(fx.State()) + cmd := network.DeleteCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - network := &hcloud.Network{ + n := &hcloud.Network{ ID: 123, Name: "test", } fx.Client.NetworkClient.EXPECT(). Get(gomock.Any(), "test"). - Return(network, nil, nil) + Return(n, nil, nil) fx.Client.NetworkClient.EXPECT(). - Delete(gomock.Any(), network). + Delete(gomock.Any(), n). Return(nil, nil) out, _, err := fx.Run(cmd, []string{"test"}) diff --git a/internal/cmd/network/describe_test.go b/internal/cmd/network/describe_test.go index f6e3627a..40a80375 100644 --- a/internal/cmd/network/describe_test.go +++ b/internal/cmd/network/describe_test.go @@ -1,4 +1,4 @@ -package network +package network_test import ( "fmt" @@ -10,6 +10,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/network" "github.com/hetznercloud/cli/internal/cmd/util" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" @@ -21,10 +22,10 @@ func TestDescribe(t *testing.T) { time.Local = time.UTC - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := network.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - network := &hcloud.Network{ + n := &hcloud.Network{ ID: 123, Name: "test", Created: time.Date(2036, 8, 12, 12, 0, 0, 0, time.UTC), @@ -35,7 +36,7 @@ func TestDescribe(t *testing.T) { fx.Client.NetworkClient.EXPECT(). Get(gomock.Any(), "test"). - Return(network, nil, nil) + Return(n, nil, nil) out, _, err := fx.Run(cmd, []string{"test"}) @@ -52,7 +53,7 @@ Protection: Delete: yes Labels: key: value -`, util.Datetime(network.Created), humanize.Time(network.Created)) +`, util.Datetime(n.Created), humanize.Time(n.Created)) assert.NoError(t, err) assert.Equal(t, expOut, out) diff --git a/internal/cmd/network/labels_test.go b/internal/cmd/network/labels_test.go index 52058b22..ebe40826 100644 --- a/internal/cmd/network/labels_test.go +++ b/internal/cmd/network/labels_test.go @@ -1,4 +1,4 @@ -package network +package network_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/network" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestLabelAdd(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.AddCobraCommand(fx.State()) + cmd := network.LabelCmds.AddCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.NetworkClient.EXPECT(). @@ -39,7 +40,7 @@ func TestLabelRemove(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.RemoveCobraCommand(fx.State()) + cmd := network.LabelCmds.RemoveCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.NetworkClient.EXPECT(). diff --git a/internal/cmd/network/update_test.go b/internal/cmd/network/update_test.go index 48e8f5ce..7b203587 100644 --- a/internal/cmd/network/update_test.go +++ b/internal/cmd/network/update_test.go @@ -1,4 +1,4 @@ -package network +package network_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/network" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUpdateName(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateCmd.CobraCommand(fx.State()) + cmd := network.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.NetworkClient.EXPECT(). diff --git a/internal/cmd/placementgroup/labels_test.go b/internal/cmd/placementgroup/labels_test.go index 83c3f53f..481921d5 100644 --- a/internal/cmd/placementgroup/labels_test.go +++ b/internal/cmd/placementgroup/labels_test.go @@ -1,4 +1,4 @@ -package placementgroup +package placementgroup_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/placementgroup" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestLabelAdd(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.AddCobraCommand(fx.State()) + cmd := placementgroup.LabelCmds.AddCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.PlacementGroupClient.EXPECT(). @@ -39,7 +40,7 @@ func TestLabelRemove(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.RemoveCobraCommand(fx.State()) + cmd := placementgroup.LabelCmds.RemoveCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.PlacementGroupClient.EXPECT(). diff --git a/internal/cmd/placementgroup/update_test.go b/internal/cmd/placementgroup/update_test.go index d3a5574c..16562632 100644 --- a/internal/cmd/placementgroup/update_test.go +++ b/internal/cmd/placementgroup/update_test.go @@ -1,4 +1,4 @@ -package placementgroup +package placementgroup_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/placementgroup" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUpdateName(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateCmd.CobraCommand(fx.State()) + cmd := placementgroup.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.PlacementGroupClient.EXPECT(). diff --git a/internal/cmd/primaryip/assign_test.go b/internal/cmd/primaryip/assign_test.go index 54332f27..0a45bec8 100644 --- a/internal/cmd/primaryip/assign_test.go +++ b/internal/cmd/primaryip/assign_test.go @@ -1,4 +1,4 @@ -package primaryip +package primaryip_test import ( "fmt" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/primaryip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -15,7 +16,7 @@ func TestAssign(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := AssignCmd.CobraCommand(fx.State()) + cmd := primaryip.AssignCmd.CobraCommand(fx.State()) action := &hcloud.Action{ID: 1} fx.ExpectEnsureToken() var ( diff --git a/internal/cmd/primaryip/changedns_test.go b/internal/cmd/primaryip/changedns_test.go index 8d79107c..0efdf422 100644 --- a/internal/cmd/primaryip/changedns_test.go +++ b/internal/cmd/primaryip/changedns_test.go @@ -1,4 +1,4 @@ -package primaryip +package primaryip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/primaryip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestChangeDNS(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := ChangeDNSCmd.CobraCommand(fx.State()) + cmd := primaryip.ChangeDNSCmd.CobraCommand(fx.State()) action := &hcloud.Action{ID: 1} fx.ExpectEnsureToken() fx.Client.PrimaryIPClient.EXPECT(). diff --git a/internal/cmd/primaryip/create_test.go b/internal/cmd/primaryip/create_test.go index 9512b100..ac5d18c2 100644 --- a/internal/cmd/primaryip/create_test.go +++ b/internal/cmd/primaryip/create_test.go @@ -1,4 +1,4 @@ -package primaryip +package primaryip_test import ( _ "embed" @@ -9,6 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/primaryip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -20,7 +21,7 @@ func TestCreate(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := primaryip.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.PrimaryIPClient.EXPECT(). Create( @@ -64,7 +65,7 @@ func TestCreateJSON(t *testing.T) { time.Local = time.UTC - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := primaryip.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.PrimaryIPClient.EXPECT(). diff --git a/internal/cmd/primaryip/delete_test.go b/internal/cmd/primaryip/delete_test.go index 567fa758..019fc36a 100644 --- a/internal/cmd/primaryip/delete_test.go +++ b/internal/cmd/primaryip/delete_test.go @@ -1,4 +1,4 @@ -package primaryip +package primaryip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/primaryip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,8 +15,8 @@ func TestDelete(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DeleteCmd.CobraCommand(fx.State()) - primaryip := &hcloud.PrimaryIP{ID: 13} + cmd := primaryip.DeleteCmd.CobraCommand(fx.State()) + ip := &hcloud.PrimaryIP{ID: 13} fx.ExpectEnsureToken() fx.Client.PrimaryIPClient.EXPECT(). Get( @@ -23,14 +24,14 @@ func TestDelete(t *testing.T) { "13", ). Return( - primaryip, + ip, &hcloud.Response{}, nil, ) fx.Client.PrimaryIPClient.EXPECT(). Delete( gomock.Any(), - primaryip, + ip, ). Return( &hcloud.Response{}, diff --git a/internal/cmd/primaryip/describe_test.go b/internal/cmd/primaryip/describe_test.go index 4f16923c..d226524b 100644 --- a/internal/cmd/primaryip/describe_test.go +++ b/internal/cmd/primaryip/describe_test.go @@ -1,4 +1,4 @@ -package primaryip +package primaryip_test import ( "fmt" @@ -10,6 +10,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/primaryip" "github.com/hetznercloud/cli/internal/cmd/util" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" @@ -21,7 +22,7 @@ func TestDescribe(t *testing.T) { time.Local = time.UTC - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := primaryip.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() primaryIP := &hcloud.PrimaryIP{ diff --git a/internal/cmd/primaryip/disable_protection_test.go b/internal/cmd/primaryip/disable_protection_test.go index bab9f567..02386098 100644 --- a/internal/cmd/primaryip/disable_protection_test.go +++ b/internal/cmd/primaryip/disable_protection_test.go @@ -1,4 +1,4 @@ -package primaryip +package primaryip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/primaryip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,9 +15,9 @@ func TestEnable(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DisableProtectionCmd.CobraCommand(fx.State()) + cmd := primaryip.DisableProtectionCmd.CobraCommand(fx.State()) action := &hcloud.Action{ID: 1} - primaryip := &hcloud.PrimaryIP{ID: 13} + ip := &hcloud.PrimaryIP{ID: 13} fx.ExpectEnsureToken() fx.Client.PrimaryIPClient.EXPECT(). Get( @@ -24,7 +25,7 @@ func TestEnable(t *testing.T) { "13", ). Return( - primaryip, + ip, &hcloud.Response{}, nil, ) diff --git a/internal/cmd/primaryip/enable_protection_test.go b/internal/cmd/primaryip/enable_protection_test.go index 141f9811..765d8f8e 100644 --- a/internal/cmd/primaryip/enable_protection_test.go +++ b/internal/cmd/primaryip/enable_protection_test.go @@ -1,4 +1,4 @@ -package primaryip +package primaryip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/primaryip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,9 +15,9 @@ func TestEnableProtection(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := EnableProtectionCmd.CobraCommand(fx.State()) + cmd := primaryip.EnableProtectionCmd.CobraCommand(fx.State()) action := &hcloud.Action{ID: 1} - primaryip := &hcloud.PrimaryIP{ID: 13} + ip := &hcloud.PrimaryIP{ID: 13} fx.ExpectEnsureToken() fx.Client.PrimaryIPClient.EXPECT(). Get( @@ -24,7 +25,7 @@ func TestEnableProtection(t *testing.T) { "13", ). Return( - primaryip, + ip, &hcloud.Response{}, nil, ) diff --git a/internal/cmd/primaryip/labels_test.go b/internal/cmd/primaryip/labels_test.go index 4aa5ab77..4e1dbeaa 100644 --- a/internal/cmd/primaryip/labels_test.go +++ b/internal/cmd/primaryip/labels_test.go @@ -1,4 +1,4 @@ -package primaryip +package primaryip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/primaryip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestLabelAdd(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.AddCobraCommand(fx.State()) + cmd := primaryip.LabelCmds.AddCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.PrimaryIPClient.EXPECT(). @@ -39,7 +40,7 @@ func TestLabelRemove(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.RemoveCobraCommand(fx.State()) + cmd := primaryip.LabelCmds.RemoveCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.PrimaryIPClient.EXPECT(). diff --git a/internal/cmd/primaryip/list_test.go b/internal/cmd/primaryip/list_test.go index 31dde821..3fe8a7f5 100644 --- a/internal/cmd/primaryip/list_test.go +++ b/internal/cmd/primaryip/list_test.go @@ -1,4 +1,4 @@ -package primaryip +package primaryip_test import ( "net" @@ -8,6 +8,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/primaryip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -16,7 +17,7 @@ func TestList(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := ListCmd.CobraCommand(fx.State()) + cmd := primaryip.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.PrimaryIPClient.EXPECT(). diff --git a/internal/cmd/primaryip/primaryip.go b/internal/cmd/primaryip/primaryip.go index 21db646a..ac2a29cf 100644 --- a/internal/cmd/primaryip/primaryip.go +++ b/internal/cmd/primaryip/primaryip.go @@ -18,7 +18,7 @@ func NewCommand(s state.State) *cobra.Command { ListCmd.CobraCommand(s), DescribeCmd.CobraCommand(s), CreateCmd.CobraCommand(s), - updateCmd.CobraCommand(s), + UpdateCmd.CobraCommand(s), DeleteCmd.CobraCommand(s), AssignCmd.CobraCommand(s), UnAssignCmd.CobraCommand(s), diff --git a/internal/cmd/primaryip/unassign_test.go b/internal/cmd/primaryip/unassign_test.go index 8dd4feae..03ac2a09 100644 --- a/internal/cmd/primaryip/unassign_test.go +++ b/internal/cmd/primaryip/unassign_test.go @@ -1,4 +1,4 @@ -package primaryip +package primaryip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/primaryip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUnAssign(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UnAssignCmd.CobraCommand(fx.State()) + cmd := primaryip.UnAssignCmd.CobraCommand(fx.State()) action := &hcloud.Action{ID: 1} fx.ExpectEnsureToken() fx.Client.PrimaryIPClient.EXPECT(). diff --git a/internal/cmd/primaryip/update.go b/internal/cmd/primaryip/update.go index 5cb81bd7..f37116dd 100644 --- a/internal/cmd/primaryip/update.go +++ b/internal/cmd/primaryip/update.go @@ -10,7 +10,7 @@ import ( "github.com/hetznercloud/hcloud-go/v2/hcloud" ) -var updateCmd = base.UpdateCmd{ +var UpdateCmd = base.UpdateCmd{ ResourceNameSingular: "Primary IP", ShortDescription: "Update a Primary IP", NameSuggestions: func(c hcapi2.Client) func() []string { return c.PrimaryIP().Names }, diff --git a/internal/cmd/primaryip/update_test.go b/internal/cmd/primaryip/update_test.go index 20c1c12e..e1956cbf 100644 --- a/internal/cmd/primaryip/update_test.go +++ b/internal/cmd/primaryip/update_test.go @@ -1,4 +1,4 @@ -package primaryip +package primaryip_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/primaryip" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUpdateName(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := updateCmd.CobraCommand(fx.State()) + cmd := primaryip.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.PrimaryIPClient.EXPECT(). @@ -38,7 +39,7 @@ func TestUpdateAutoDelete(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := updateCmd.CobraCommand(fx.State()) + cmd := primaryip.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.PrimaryIPClient.EXPECT(). diff --git a/internal/cmd/server/delete_test.go b/internal/cmd/server/delete_test.go index 83bfca3e..ac6a6c10 100644 --- a/internal/cmd/server/delete_test.go +++ b/internal/cmd/server/delete_test.go @@ -1,4 +1,4 @@ -package server +package server_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/server" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDelete(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DeleteCmd.CobraCommand(fx.State()) + cmd := server.DeleteCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() srv := &hcloud.Server{ diff --git a/internal/cmd/server/describe_test.go b/internal/cmd/server/describe_test.go index 48b3b496..aab3ffd9 100644 --- a/internal/cmd/server/describe_test.go +++ b/internal/cmd/server/describe_test.go @@ -1,4 +1,4 @@ -package server +package server_test import ( "fmt" @@ -9,6 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/server" "github.com/hetznercloud/cli/internal/cmd/util" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" @@ -20,7 +21,7 @@ func TestDescribe(t *testing.T) { time.Local = time.UTC - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := server.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() srv := &hcloud.Server{ diff --git a/internal/cmd/server/labels_test.go b/internal/cmd/server/labels_test.go index 03d22c53..1daf3570 100644 --- a/internal/cmd/server/labels_test.go +++ b/internal/cmd/server/labels_test.go @@ -1,4 +1,4 @@ -package server +package server_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/server" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestLabelAdd(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.AddCobraCommand(fx.State()) + cmd := server.LabelCmds.AddCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ServerClient.EXPECT(). @@ -39,7 +40,7 @@ func TestLabelRemove(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.RemoveCobraCommand(fx.State()) + cmd := server.LabelCmds.RemoveCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ServerClient.EXPECT(). diff --git a/internal/cmd/server/list_test.go b/internal/cmd/server/list_test.go index 6c1333cf..796b0a0c 100644 --- a/internal/cmd/server/list_test.go +++ b/internal/cmd/server/list_test.go @@ -1,4 +1,4 @@ -package server +package server_test import ( "net" @@ -8,6 +8,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/server" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -18,7 +19,7 @@ func TestList(t *testing.T) { time.Local = time.UTC - cmd := ListCmd.CobraCommand(fx.State()) + cmd := server.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ServerClient.EXPECT(). diff --git a/internal/cmd/server/remove_from_placement_group_test.go b/internal/cmd/server/remove_from_placement_group_test.go index 935f85f1..94697fdd 100644 --- a/internal/cmd/server/remove_from_placement_group_test.go +++ b/internal/cmd/server/remove_from_placement_group_test.go @@ -18,19 +18,19 @@ func TestRemoveFromPlacementGroup(t *testing.T) { cmd := server.RemoveFromPlacementGroupCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - server := hcloud.Server{ + srv := hcloud.Server{ ID: 42, Name: "my server", } fx.Client.ServerClient.EXPECT(). - Get(gomock.Any(), server.Name). - Return(&server, nil, nil) + Get(gomock.Any(), srv.Name). + Return(&srv, nil, nil) fx.Client.ServerClient.EXPECT(). - RemoveFromPlacementGroup(gomock.Any(), &server) + RemoveFromPlacementGroup(gomock.Any(), &srv) fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), nil) - out, _, err := fx.Run(cmd, []string{server.Name}) + out, _, err := fx.Run(cmd, []string{srv.Name}) expOut := `Server 42 removed from placement group ` diff --git a/internal/cmd/server/shutdown_test.go b/internal/cmd/server/shutdown_test.go index 1ca5ba5f..ea1f8e35 100644 --- a/internal/cmd/server/shutdown_test.go +++ b/internal/cmd/server/shutdown_test.go @@ -1,4 +1,4 @@ -package server +package server_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/server" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -15,26 +16,24 @@ func TestShutdown(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := ShutdownCmd.CobraCommand(fx.State()) + cmd := server.ShutdownCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - var ( - server = hcloud.Server{ - ID: 42, - Name: "my server", - Status: hcloud.ServerStatusRunning, - } - ) + srv := hcloud.Server{ + ID: 42, + Name: "my server", + Status: hcloud.ServerStatusRunning, + } fx.Client.ServerClient.EXPECT(). - Get(gomock.Any(), server.Name). - Return(&server, nil, nil) + Get(gomock.Any(), srv.Name). + Return(&srv, nil, nil) fx.Client.ServerClient.EXPECT(). - Shutdown(gomock.Any(), &server) + Shutdown(gomock.Any(), &srv) fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), nil) - out, _, err := fx.Run(cmd, []string{server.Name}) + out, _, err := fx.Run(cmd, []string{srv.Name}) expOut := "Sent shutdown signal to server 42\n" @@ -47,32 +46,30 @@ func TestShutdownWait(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := ShutdownCmd.CobraCommand(fx.State()) + cmd := server.ShutdownCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - var ( - server = hcloud.Server{ - ID: 42, - Name: "my server", - Status: hcloud.ServerStatusRunning, - } - ) + srv := hcloud.Server{ + ID: 42, + Name: "my server", + Status: hcloud.ServerStatusRunning, + } fx.Client.ServerClient.EXPECT(). - Get(gomock.Any(), server.Name). - Return(&server, nil, nil) + Get(gomock.Any(), srv.Name). + Return(&srv, nil, nil) fx.Client.ServerClient.EXPECT(). - Shutdown(gomock.Any(), &server) + Shutdown(gomock.Any(), &srv) fx.ActionWaiter.EXPECT().ActionProgress(gomock.Any(), gomock.Any(), nil) fx.Client.ServerClient.EXPECT(). - GetByID(gomock.Any(), server.ID). - Return(&server, nil, nil). - Return(&server, nil, nil). - Return(&hcloud.Server{ID: server.ID, Name: server.Name, Status: hcloud.ServerStatusOff}, nil, nil) + GetByID(gomock.Any(), srv.ID). + Return(&srv, nil, nil). + Return(&srv, nil, nil). + Return(&hcloud.Server{ID: srv.ID, Name: srv.Name, Status: hcloud.ServerStatusOff}, nil, nil) - out, _, err := fx.Run(cmd, []string{server.Name, "--wait"}) + out, _, err := fx.Run(cmd, []string{srv.Name, "--wait"}) expOut := "Sent shutdown signal to server 42\nServer 42 shut down\n" diff --git a/internal/cmd/server/update_test.go b/internal/cmd/server/update_test.go index 82595e4a..d64ae3e9 100644 --- a/internal/cmd/server/update_test.go +++ b/internal/cmd/server/update_test.go @@ -1,4 +1,4 @@ -package server +package server_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/server" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUpdateName(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateCmd.CobraCommand(fx.State()) + cmd := server.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ServerClient.EXPECT(). diff --git a/internal/cmd/servertype/describe_test.go b/internal/cmd/servertype/describe_test.go index d9565f3a..68b19af3 100644 --- a/internal/cmd/servertype/describe_test.go +++ b/internal/cmd/servertype/describe_test.go @@ -1,4 +1,4 @@ -package servertype +package servertype_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/servertype" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDescribe(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := servertype.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ServerTypeClient.EXPECT(). diff --git a/internal/cmd/servertype/list_test.go b/internal/cmd/servertype/list_test.go index f16128a4..2ed3b9a8 100644 --- a/internal/cmd/servertype/list_test.go +++ b/internal/cmd/servertype/list_test.go @@ -1,4 +1,4 @@ -package servertype +package servertype_test import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/servertype" "github.com/hetznercloud/cli/internal/cmd/util" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" @@ -18,7 +19,7 @@ func TestList(t *testing.T) { time.Local = time.UTC - cmd := ListCmd.CobraCommand(fx.State()) + cmd := servertype.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.ServerTypeClient.EXPECT(). diff --git a/internal/cmd/sshkey/create_test.go b/internal/cmd/sshkey/create_test.go index e22b2c36..e2f3bb80 100644 --- a/internal/cmd/sshkey/create_test.go +++ b/internal/cmd/sshkey/create_test.go @@ -1,4 +1,4 @@ -package sshkey +package sshkey_test import ( _ "embed" @@ -8,6 +8,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/sshkey" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -19,7 +20,7 @@ func TestCreate(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := sshkey.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.SSHKeyClient.EXPECT(). @@ -48,7 +49,7 @@ func TestCreateJSON(t *testing.T) { time.Local = time.UTC - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := sshkey.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.SSHKeyClient.EXPECT(). diff --git a/internal/cmd/sshkey/delete_test.go b/internal/cmd/sshkey/delete_test.go index f6f47379..14640a11 100644 --- a/internal/cmd/sshkey/delete_test.go +++ b/internal/cmd/sshkey/delete_test.go @@ -1,4 +1,4 @@ -package sshkey +package sshkey_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/sshkey" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestDelete(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DeleteCmd.CobraCommand(fx.State()) + cmd := sshkey.DeleteCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() sshKey := &hcloud.SSHKey{ diff --git a/internal/cmd/sshkey/describe_test.go b/internal/cmd/sshkey/describe_test.go index 8b6008b1..8e083b51 100644 --- a/internal/cmd/sshkey/describe_test.go +++ b/internal/cmd/sshkey/describe_test.go @@ -1,4 +1,4 @@ -package sshkey +package sshkey_test import ( "fmt" @@ -9,6 +9,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/sshkey" "github.com/hetznercloud/cli/internal/cmd/util" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" @@ -20,7 +21,7 @@ func TestDescribe(t *testing.T) { time.Local = time.UTC - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := sshkey.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() key := &hcloud.SSHKey{ diff --git a/internal/cmd/sshkey/labels_test.go b/internal/cmd/sshkey/labels_test.go index d293ee6f..3b5d388b 100644 --- a/internal/cmd/sshkey/labels_test.go +++ b/internal/cmd/sshkey/labels_test.go @@ -1,4 +1,4 @@ -package sshkey +package sshkey_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/sshkey" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestLabelAdd(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.AddCobraCommand(fx.State()) + cmd := sshkey.LabelCmds.AddCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.SSHKeyClient.EXPECT(). @@ -39,7 +40,7 @@ func TestLabelRemove(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.RemoveCobraCommand(fx.State()) + cmd := sshkey.LabelCmds.RemoveCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.SSHKeyClient.EXPECT(). diff --git a/internal/cmd/sshkey/list_test.go b/internal/cmd/sshkey/list_test.go index 8e18e44d..1e9a94f5 100644 --- a/internal/cmd/sshkey/list_test.go +++ b/internal/cmd/sshkey/list_test.go @@ -1,4 +1,4 @@ -package sshkey +package sshkey_test import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/sshkey" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -17,7 +18,7 @@ func TestList(t *testing.T) { time.Local = time.UTC - cmd := ListCmd.CobraCommand(fx.State()) + cmd := sshkey.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.SSHKeyClient.EXPECT(). diff --git a/internal/cmd/sshkey/update_test.go b/internal/cmd/sshkey/update_test.go index 0d516b66..155adaf9 100644 --- a/internal/cmd/sshkey/update_test.go +++ b/internal/cmd/sshkey/update_test.go @@ -1,4 +1,4 @@ -package sshkey +package sshkey_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/sshkey" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUpdateName(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateCmd.CobraCommand(fx.State()) + cmd := sshkey.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.SSHKeyClient.EXPECT(). diff --git a/internal/cmd/volume/create_test.go b/internal/cmd/volume/create_test.go index 2a45093d..c98c7889 100644 --- a/internal/cmd/volume/create_test.go +++ b/internal/cmd/volume/create_test.go @@ -1,4 +1,4 @@ -package volume +package volume_test import ( _ "embed" @@ -8,6 +8,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/volume" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -19,7 +20,7 @@ func TestCreate(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := volume.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.VolumeClient.EXPECT(). @@ -58,7 +59,7 @@ func TestCreateJSON(t *testing.T) { time.Local = time.UTC - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := volume.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.VolumeClient.EXPECT(). @@ -103,10 +104,10 @@ func TestCreateProtection(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := CreateCmd.CobraCommand(fx.State()) + cmd := volume.CreateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - volume := &hcloud.Volume{ + v := &hcloud.Volume{ ID: 123, Name: "test", Size: 20, @@ -121,7 +122,7 @@ func TestCreateProtection(t *testing.T) { Labels: make(map[string]string), }). Return(hcloud.VolumeCreateResult{ - Volume: volume, + Volume: v, Action: &hcloud.Action{ID: 321}, NextActions: []*hcloud.Action{{ID: 1}, {ID: 2}, {ID: 3}}, }, nil, nil) @@ -130,7 +131,7 @@ func TestCreateProtection(t *testing.T) { fx.ActionWaiter.EXPECT(). WaitForActions(gomock.Any(), gomock.Any(), []*hcloud.Action{{ID: 1}, {ID: 2}, {ID: 3}}) fx.Client.VolumeClient.EXPECT(). - ChangeProtection(gomock.Any(), volume, hcloud.VolumeChangeProtectionOpts{ + ChangeProtection(gomock.Any(), v, hcloud.VolumeChangeProtectionOpts{ Delete: hcloud.Ptr(true), }). Return(&hcloud.Action{ID: 123}, nil, nil) diff --git a/internal/cmd/volume/delete_test.go b/internal/cmd/volume/delete_test.go index a4ce604d..5f7613a9 100644 --- a/internal/cmd/volume/delete_test.go +++ b/internal/cmd/volume/delete_test.go @@ -1,4 +1,4 @@ -package volume +package volume_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/volume" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,19 +15,19 @@ func TestDelete(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := DeleteCmd.CobraCommand(fx.State()) + cmd := volume.DeleteCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - volume := &hcloud.Volume{ + v := &hcloud.Volume{ ID: 123, Name: "test", } fx.Client.VolumeClient.EXPECT(). Get(gomock.Any(), "test"). - Return(volume, nil, nil) + Return(v, nil, nil) fx.Client.VolumeClient.EXPECT(). - Delete(gomock.Any(), volume). + Delete(gomock.Any(), v). Return(nil, nil) out, _, err := fx.Run(cmd, []string{"test"}) diff --git a/internal/cmd/volume/describe_test.go b/internal/cmd/volume/describe_test.go index abf09aa5..94124fd2 100644 --- a/internal/cmd/volume/describe_test.go +++ b/internal/cmd/volume/describe_test.go @@ -1,4 +1,4 @@ -package volume +package volume_test import ( "fmt" @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/hetznercloud/cli/internal/cmd/util" + "github.com/hetznercloud/cli/internal/cmd/volume" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -20,10 +21,10 @@ func TestDescribe(t *testing.T) { time.Local = time.UTC - cmd := DescribeCmd.CobraCommand(fx.State()) + cmd := volume.DescribeCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() - volume := &hcloud.Volume{ + v := &hcloud.Volume{ ID: 123, Name: "test", Size: 50, @@ -43,7 +44,7 @@ func TestDescribe(t *testing.T) { fx.Client.VolumeClient.EXPECT(). Get(gomock.Any(), "test"). - Return(volume, nil, nil) + Return(v, nil, nil) fx.Client.ServerClient.EXPECT(). ServerName(int64(321)). Return("myServer") @@ -69,7 +70,7 @@ Protection: Delete: no Labels: No labels -`, util.Datetime(volume.Created), humanize.Time(volume.Created)) +`, util.Datetime(v.Created), humanize.Time(v.Created)) assert.NoError(t, err) assert.Equal(t, expOut, out) diff --git a/internal/cmd/volume/labels_test.go b/internal/cmd/volume/labels_test.go index 6bc15220..fe8cb952 100644 --- a/internal/cmd/volume/labels_test.go +++ b/internal/cmd/volume/labels_test.go @@ -1,4 +1,4 @@ -package volume +package volume_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/volume" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestLabelAdd(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.AddCobraCommand(fx.State()) + cmd := volume.LabelCmds.AddCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.VolumeClient.EXPECT(). @@ -39,7 +40,7 @@ func TestLabelRemove(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := LabelCmds.RemoveCobraCommand(fx.State()) + cmd := volume.LabelCmds.RemoveCobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.VolumeClient.EXPECT(). diff --git a/internal/cmd/volume/list_test.go b/internal/cmd/volume/list_test.go index d932a82f..5fda734f 100644 --- a/internal/cmd/volume/list_test.go +++ b/internal/cmd/volume/list_test.go @@ -1,4 +1,4 @@ -package volume +package volume_test import ( "testing" @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/volume" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -17,7 +18,7 @@ func TestList(t *testing.T) { time.Local = time.UTC - cmd := ListCmd.CobraCommand(fx.State()) + cmd := volume.ListCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.VolumeClient.EXPECT(). diff --git a/internal/cmd/volume/update_test.go b/internal/cmd/volume/update_test.go index 9117e27a..2e65b6a3 100644 --- a/internal/cmd/volume/update_test.go +++ b/internal/cmd/volume/update_test.go @@ -1,4 +1,4 @@ -package volume +package volume_test import ( "testing" @@ -6,6 +6,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" + "github.com/hetznercloud/cli/internal/cmd/volume" "github.com/hetznercloud/cli/internal/testutil" "github.com/hetznercloud/hcloud-go/v2/hcloud" ) @@ -14,7 +15,7 @@ func TestUpdateName(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() - cmd := UpdateCmd.CobraCommand(fx.State()) + cmd := volume.UpdateCmd.CobraCommand(fx.State()) fx.ExpectEnsureToken() fx.Client.VolumeClient.EXPECT().