Skip to content

Commit

Permalink
Fixed the tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
fbarl committed May 15, 2018
1 parent c20109e commit ad6d996
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 6 additions & 1 deletion probe/docker/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ func (r *registry) WalkNetworks(f func(docker_client.Network)) {
}
}

// ImageNameParts returns parts of the full image name (image name, image tag).
func ImageNameParts(name string) []string {
parts := strings.SplitN(name, "/", 3)
if len(parts) == 3 {
Expand All @@ -488,5 +489,9 @@ func ImageNameWithoutVersion(name string) string {

// ImageNameVersion splits the image name apart, returning the version, if possible
func ImageNameVersion(name string) string {
return ImageNameParts(name)[1]
imageNameParts := ImageNameParts(name)
if len(imageNameParts) < 2 {
return ""
}
return imageNameParts[1]
}
6 changes: 3 additions & 3 deletions render/detailed/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ func TestMakeDetailedContainerNode(t *testing.T) {
Pseudo: false,
},
Metadata: []report.MetadataRow{
{ID: "docker_image_name", Label: "Image", Value: fixture.ServerContainerImageName, Priority: 1},
{ID: "docker_container_state_human", Label: "State", Value: "running", Priority: 3},
{ID: "docker_container_id", Label: "ID", Value: fixture.ServerContainerID, Priority: 10, Truncate: 12},
{ID: "docker_image_name", Label: "Image name", Value: fixture.ServerContainerImageName, Priority: 2},
{ID: "docker_container_state_human", Label: "State", Value: "running", Priority: 4},
{ID: "docker_container_id", Label: "ID", Value: fixture.ServerContainerID, Priority: 11, Truncate: 12},
},
Metrics: []report.MetricRow{
{
Expand Down
10 changes: 5 additions & 5 deletions render/detailed/summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ func TestMakeNodeSummary(t *testing.T) {
Shape: "hexagon",
},
Metadata: []report.MetadataRow{
{ID: docker.ImageName, Label: "Image", Value: fixture.ClientContainerImageName, Priority: 1},
{ID: docker.ContainerID, Label: "ID", Value: fixture.ClientContainerID, Priority: 10, Truncate: 12},
{ID: docker.ImageName, Label: "Image name", Value: fixture.ClientContainerImageName, Priority: 2},
{ID: docker.ContainerID, Label: "ID", Value: fixture.ClientContainerID, Priority: 11, Truncate: 12},
},
Adjacency: report.MakeIDList(fixture.ServerContainerNodeID),
},
Expand Down Expand Up @@ -252,9 +252,9 @@ func TestNodeMetadata(t *testing.T) {
Add(docker.ContainerIPs, report.MakeStringSet("10.10.10.0/24", "10.10.10.1/24")),
),
want: []report.MetadataRow{
{ID: docker.ContainerStateHuman, Label: "State", Value: "running", Priority: 3},
{ID: docker.ContainerIPs, Label: "IPs", Value: "10.10.10.0/24, 10.10.10.1/24", Priority: 7},
{ID: docker.ContainerID, Label: "ID", Value: fixture.ClientContainerID, Priority: 10, Truncate: 12},
{ID: docker.ContainerStateHuman, Label: "State", Value: "running", Priority: 4},
{ID: docker.ContainerIPs, Label: "IPs", Value: "10.10.10.0/24, 10.10.10.1/24", Priority: 8},
{ID: docker.ContainerID, Label: "ID", Value: fixture.ClientContainerID, Priority: 11, Truncate: 12},
},
},
{
Expand Down

0 comments on commit ad6d996

Please sign in to comment.