Skip to content

Commit

Permalink
Add k8s hardware export unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Doherty <[email protected]>
  • Loading branch information
chrisdoherty4 committed Apr 21, 2022
1 parent cadf0c3 commit c8a1202
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions hardware/kubernetes_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package hardware_test

import (
"context"
"encoding/json"
"testing"

"github.com/pkg/errors"
Expand Down Expand Up @@ -118,6 +119,46 @@ func TestKubernetesClientHealthyAndClose(t *testing.T) {
assert.False(t, client.IsHealthy(context.Background()))
}

func TestK8sHardwareExport(t *testing.T) {
userdata := "hello-world"
hw := hardware.K8sHardware{
Metadata: hardware.K8sHardwareMetadata{
Userdata: &userdata,
Instance: hardware.K8sHardwareMetadataInstance{
ID: "id",
Hostname: "hostname",
Plan: "plan",
Factility: "facility",
Tags: []string{"foo", "bar"},
SSHKeys: []string{"baz", "qux"},
OperatingSystem: hardware.K8sHardwareMetadataInstanceOperatingSystem{
Slug: "slug",
Distro: "distro",
Version: "version",
ImageTag: "imagetag",
},
Network: hardware.K8sHardwareMetadataInstanceNetwork{
Addresses: []hardware.K8sHardwareMetadataInstanceNetworkAddress{
{
AddressFamily: 4,
Address: "1.1.1.1",
Public: true,
},
},
},
},
},
}

expect, err := json.Marshal(hw)
require.NoError(t, err)

actual, err := hw.Export()
require.NoError(t, err)

assert.Equal(t, expect, actual)
}

type ListerClientMock struct {
mock.Mock
}
Expand Down

0 comments on commit c8a1202

Please sign in to comment.