Skip to content

Commit

Permalink
update jam summarize to omit stacks information if none are present i…
Browse files Browse the repository at this point in the history
…n buildpack toml

- Lets us use this command to get a summary of metabuildpack .tgz files.

Signed-off-by: Ryan Moran <[email protected]>
  • Loading branch information
ForestEckhardt authored and Ryan Moran committed May 7, 2020
1 parent 530dc50 commit c376492
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cargo/jam/internal/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ func (f Formatter) Markdown(dependencies []cargo.ConfigMetadataDependency, defau

sort.Strings(stacks)

fmt.Fprintf(f.writer, "Supported stacks:\n| name |\n|-|\n")
for _, s := range stacks {
fmt.Fprintf(f.writer, "| %s |\n", s)
if len(stacks) > 0 {
fmt.Fprintf(f.writer, "Supported stacks:\n| name |\n|-|\n")
for _, s := range stacks {
fmt.Fprintf(f.writer, "| %s |\n", s)
}
}
}
47 changes: 47 additions & 0 deletions cargo/jam/internal/formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,53 @@ Supported stacks:
|-|
| other-stack |
| some-stack |
`))
})
})

context("when stacks are empty", func() {
it("returns a list of dependencies", func() {
dependencies := []cargo.ConfigMetadataDependency{
{
ID: "some-dependency",
Stacks: []string{"some-stack"},
Version: "1.2.3",
},
{
ID: "some-dependency",
Stacks: []string{"other-stack"},
Version: "1.2.3",
},
{
ID: "other-dependency",
Stacks: []string{"some-stack", "other-stack"},
Version: "2.3.4",
},
{
ID: "other-dependency",
Stacks: []string{"other-stack"},
Version: "2.3.5",
},
}
defaults := map[string]string{
"some-dependency": "1.2.x",
"other-dependency": "2.3.x",
}

formatter.Markdown(dependencies, defaults, nil)
Expect(buffer.String()).To(Equal(`Dependencies:
| name | version | stacks |
|-|-|-|
| other-dependency | 2.3.5 | other-stack |
| other-dependency | 2.3.4 | other-stack, some-stack |
| some-dependency | 1.2.3 | other-stack, some-stack |
Default dependencies:
| name | version |
|-|-|
| other-dependency | 2.3.x |
| some-dependency | 1.2.x |
`))
})
})
Expand Down

0 comments on commit c376492

Please sign in to comment.