Skip to content

Commit 4c4328a

Browse files
committed
fix unit test
1 parent 265ebf6 commit 4c4328a

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

pkg/cli/cli_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,17 @@ func (r *result) RequireStdout(t *testing.T, lines []string) {
113113
stdout := strings.Split(strings.TrimSuffix(r.Stdout, "\n"), "\n")
114114
require.Equal(t, lines, stdout)
115115
}
116+
117+
func (r *result) RequireStdoutWithSkipPrefix(t *testing.T, lines []string, skipPrefix string) {
118+
stdout := strings.Split(strings.TrimSuffix(r.Stdout, "\n"), "\n")
119+
120+
finalStdout := make([]string, 0, len(stdout))
121+
for i := range stdout {
122+
if strings.HasPrefix(stdout[i], skipPrefix) {
123+
continue
124+
}
125+
finalStdout = append(finalStdout, stdout[i])
126+
}
127+
128+
require.Equal(t, lines, finalStdout)
129+
}

pkg/cli/releases_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cli_test
33
import (
44
"fmt"
55
"testing"
6-
"time"
76

87
"github.com/convox/rack/pkg/cli"
98
mocksdk "github.com/convox/rack/pkg/mock/sdk"
@@ -50,14 +49,13 @@ func TestReleasesInfo(t *testing.T) {
5049
require.NoError(t, err)
5150
require.Equal(t, 0, res.Code)
5251
res.RequireStderr(t, []string{""})
53-
res.RequireStdout(t, []string{
52+
res.RequireStdoutWithSkipPrefix(t, []string{
5453
"Id release1",
5554
"Build build1",
56-
fmt.Sprintf("Created %s", fxRelease().Created.Format(time.RFC3339)),
5755
"Description description1",
5856
"Env FOO=bar",
5957
" BAZ=quux",
60-
})
58+
}, "Created ")
6159
})
6260
}
6361

provider/aws/system_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestSystemGet(t *testing.T) {
4040
Type: "t2.small",
4141
Version: "dev",
4242
Outputs: map[string]string{},
43-
Parameters: map[string]string{"Autoscale": "No", "SubnetPrivate2CIDR": "10.0.6.0/24", "Subnet0CIDR": "10.0.1.0/24", "Encryption": "Yes", "Development": "Yes", "Private": "No", "InstanceUpdateBatchSize": "1", "InstanceRunCommand": "", "ExistingVpc": "", "PrivateApi": "No", "ContainerDisk": "10", "Ami": "", "VolumeSize": "50", "Tenancy": "default", "Version": "dev", "VPCCIDR": "10.0.0.0/16", "Subnet2CIDR": "10.0.3.0/24", "InstanceType": "t2.small", "Password": "****", "Key": "convox-keypair-4415", "ApiCpu": "128", "SwapSize": "5", "ApiMemory": "128", "SubnetPrivate0CIDR": "10.0.4.0/24", "InstanceCount": "3", "InstanceBootCommand": "", "Internal": "No", "Subnet1CIDR": "10.0.2.0/24", "ClientId": "nmert38iwdsrj362jdf", "SubnetPrivate1CIDR": "10.0.5.0/24"},
43+
Parameters: map[string]string{"Autoscale": "No", "SubnetPrivate2CIDR": "10.0.6.0/24", "Subnet0CIDR": "10.0.1.0/24", "Encryption": "Yes", "Development": "Yes", "Private": "No", "InstanceUpdateBatchSize": "1", "InstanceRunCommand": "", "ExistingVpc": "", "PrivateApi": "No", "ContainerDisk": "10", "Ami": "", "VolumeSize": "50", "Tags": "", "Tenancy": "default", "Version": "dev", "VPCCIDR": "10.0.0.0/16", "Subnet2CIDR": "10.0.3.0/24", "InstanceType": "t2.small", "Password": "****", "Key": "convox-keypair-4415", "ApiCpu": "128", "SwapSize": "5", "ApiMemory": "128", "SubnetPrivate0CIDR": "10.0.4.0/24", "InstanceCount": "3", "InstanceBootCommand": "", "Internal": "No", "Subnet1CIDR": "10.0.2.0/24", "ClientId": "nmert38iwdsrj362jdf", "SubnetPrivate1CIDR": "10.0.5.0/24"},
4444
}, s)
4545
}
4646

@@ -64,7 +64,7 @@ func TestSystemGetConverging(t *testing.T) {
6464
Type: "t2.small",
6565
Version: "dev",
6666
Outputs: map[string]string{},
67-
Parameters: map[string]string{"Autoscale": "No", "SubnetPrivate2CIDR": "10.0.6.0/24", "Subnet0CIDR": "10.0.1.0/24", "Encryption": "Yes", "Development": "Yes", "Private": "No", "InstanceUpdateBatchSize": "1", "InstanceRunCommand": "", "ExistingVpc": "", "PrivateApi": "No", "ContainerDisk": "10", "Ami": "", "VolumeSize": "50", "Tenancy": "default", "Version": "dev", "VPCCIDR": "10.0.0.0/16", "Subnet2CIDR": "10.0.3.0/24", "InstanceType": "t2.small", "Password": "****", "Key": "convox-keypair-4415", "ApiCpu": "128", "SwapSize": "5", "ApiMemory": "128", "SubnetPrivate0CIDR": "10.0.4.0/24", "InstanceCount": "3", "InstanceBootCommand": "", "Internal": "No", "Subnet1CIDR": "10.0.2.0/24", "ClientId": "nmert38iwdsrj362jdf", "SubnetPrivate1CIDR": "10.0.5.0/24"},
67+
Parameters: map[string]string{"Autoscale": "No", "SubnetPrivate2CIDR": "10.0.6.0/24", "Subnet0CIDR": "10.0.1.0/24", "Encryption": "Yes", "Development": "Yes", "Private": "No", "InstanceUpdateBatchSize": "1", "InstanceRunCommand": "", "ExistingVpc": "", "PrivateApi": "No", "ContainerDisk": "10", "Ami": "", "VolumeSize": "50", "Tags": "", "Tenancy": "default", "Version": "dev", "VPCCIDR": "10.0.0.0/16", "Subnet2CIDR": "10.0.3.0/24", "InstanceType": "t2.small", "Password": "****", "Key": "convox-keypair-4415", "ApiCpu": "128", "SwapSize": "5", "ApiMemory": "128", "SubnetPrivate0CIDR": "10.0.4.0/24", "InstanceCount": "3", "InstanceBootCommand": "", "Internal": "No", "Subnet1CIDR": "10.0.2.0/24", "ClientId": "nmert38iwdsrj362jdf", "SubnetPrivate1CIDR": "10.0.5.0/24"},
6868
}, s)
6969
}
7070

0 commit comments

Comments
 (0)