Skip to content

Commit

Permalink
Merge pull request #5 from viovanov/f0rmiga/index-int
Browse files Browse the repository at this point in the history
Fix when Index = 0, render incorrect spec.index
  • Loading branch information
Thulio Ferraz Assis committed Jul 11, 2019
2 parents 753a0fd + bc7488d commit 6b63570
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion assets/instance_info_test.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= spec.index %> <%= spec.address %> <%= spec.az %> <%= spec.deployment %> <%= spec.id %> <%= spec.ip %>
<%= spec.address %> <%= spec.az %> <%= spec.bootstrap %> <%= spec.deployment %> <%= spec.id %> <%= spec.index %> <%= spec.ip %> <%= spec.name %>
2 changes: 1 addition & 1 deletion assets/simple_test.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= p('foo') %>
<%= p('foo') %>
2 changes: 1 addition & 1 deletion bosh_template_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type InstanceInfo struct {
AZ string `yaml:"az"`
Deployment string `yaml:"deployment"`
ID string `yaml:"id"`
Index string `yaml:"index"`
Index int `yaml:"index"`
IP string `yaml:"ip"`
Name string `yaml:"name"`
}
Expand Down
16 changes: 8 additions & 8 deletions bosh_template_go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestRenderOK(t *testing.T) {

// Assert
assert.NoError(err)
assert.Equal("bar", string(output))
assert.Equal("bar\n", string(output))
}

func TestRenderDefaultValueFromSpec(t *testing.T) {
Expand All @@ -154,7 +154,7 @@ func TestRenderDefaultValueFromSpec(t *testing.T) {

// Assert
assert.NoError(err)
assert.Equal("baz", string(output))
assert.Equal("baz\n", string(output))
}

func TestRenderWithInstanceInfo(t *testing.T) {
Expand All @@ -173,7 +173,7 @@ func TestRenderWithInstanceInfo(t *testing.T) {
Deployment: "mydeployment",
ID: "005443",
IP: "256.256.256.256",
Index: "123",
Index: 123,
Name: "foo",
},
jobSpecFile)
Expand All @@ -189,7 +189,7 @@ func TestRenderWithInstanceInfo(t *testing.T) {

// Assert
assert.NoError(err)
assert.Equal("123 foo.deadbeef.com myaz mydeployment 005443 256.256.256.256", string(output))
assert.Equal("foo.deadbeef.com myaz false mydeployment 005443 123 256.256.256.256 foo\n", string(output))
}

func TestRenderWithLinks(t *testing.T) {
Expand All @@ -209,7 +209,7 @@ func TestRenderWithLinks(t *testing.T) {
"address": "link.domain.foo",
"az": "linkaz",
"id": "11nk1d",
"index": "11",
"index": 11,
"name": "linkedjob",
},
},
Expand All @@ -224,7 +224,7 @@ func TestRenderWithLinks(t *testing.T) {
Deployment: "mydeployment",
ID: "005443",
IP: "256.256.256.256",
Index: "123",
Index: 123,
Name: "foo",
},
jobSpecFile)
Expand Down Expand Up @@ -260,7 +260,7 @@ func TestRenderWithLinkProperty(t *testing.T) {
"address": "link.domain.foo",
"az": "linkaz",
"id": "11nk1d",
"index": "11",
"index": 11,
"name": "linkedjob",
},
},
Expand All @@ -278,7 +278,7 @@ func TestRenderWithLinkProperty(t *testing.T) {
Deployment: "mydeployment",
ID: "005443",
IP: "256.256.256.256",
Index: "123",
Index: 123,
Name: "foo",
},
jobSpecFile)
Expand Down

0 comments on commit 6b63570

Please sign in to comment.