Skip to content

Commit

Permalink
Merge branch 'main' into include-dependabot-in-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Dec 5, 2022
2 parents 551c0ac + b7cdaad commit 6012946
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 79 deletions.
6 changes: 4 additions & 2 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,13 @@ func generateMkdocs(rootDir string, exampleLower string) error {

// make sure the index.md is the first element in the list of examples in the nav
examplesNav := make([]string, len(mkdocsExamplesNav)-1)
j := 0

for _, exampleNav := range mkdocsExamplesNav {
// filter out the index.md file
if !strings.HasSuffix("index.md", exampleNav) {
examplesNav = append(examplesNav, exampleNav)
if !strings.HasSuffix(exampleNav, "index.md") {
examplesNav[j] = exampleNav
j++
}
}

Expand Down
12 changes: 9 additions & 3 deletions examples/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ func TestGenerate(t *testing.T) {
err = copyInitialMkdocsConfig(t, rootTmp)
assert.Nil(t, err)

originalConfig, err := readMkdocsConfig(rootTmp)
assert.Nil(t, err)

err = copyInitialDependabotConfig(t, rootTmp)
assert.Nil(t, err)

Expand Down Expand Up @@ -115,7 +118,7 @@ func TestGenerate(t *testing.T) {
assertGoModContent(t, example, filepath.Join(generatedTemplatesDir, "go.mod"))
assertMakefileContent(t, example, filepath.Join(generatedTemplatesDir, "Makefile"))
assertToolsGoContent(t, example, filepath.Join(generatedTemplatesDir, "tools", "tools.go"))
assertMkdocsExamplesNav(t, example, rootTmp)
assertMkdocsExamplesNav(t, example, originalConfig, rootTmp)
assertDependabotExamplesUpdates(t, example, originalDependabotConfig, rootTmp)
}

Expand Down Expand Up @@ -230,12 +233,15 @@ func assertMakefileContent(t *testing.T, example Example, makefile string) {
}

// assert content in the Examples nav from mkdocs.yml
func assertMkdocsExamplesNav(t *testing.T, example Example, rootDir string) {
func assertMkdocsExamplesNav(t *testing.T, example Example, originalConfig *MkDocsConfig, rootDir string) {
config, err := readMkdocsConfig(rootDir)
assert.Nil(t, err)

// the example should be in the nav
examples := config.Nav[3].Examples

assert.Equal(t, len(originalConfig.Nav[3].Examples)+1, len(examples))

// the example should be in the nav
found := false
for _, ex := range examples {
markdownExample := "examples/" + example.Lower() + ".md"
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/cenkalti/backoff/v4 v4.1.3
github.com/compose-spec/compose-go v1.6.0
github.com/containerd/containerd v1.6.8
github.com/containerd/containerd v1.6.10
github.com/docker/cli v20.10.19+incompatible
github.com/docker/compose/v2 v2.12.2
github.com/docker/docker v20.10.19+incompatible
Expand All @@ -19,7 +19,7 @@ require (
github.com/opencontainers/image-spec v1.0.3-0.20220303224323-02efb9a75ee1
github.com/stretchr/testify v1.8.0
golang.org/x/sync v0.1.0
golang.org/x/sys v0.1.0
golang.org/x/sys v0.3.0
golang.org/x/text v0.3.7
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -125,6 +125,7 @@ require (
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/cobra v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.4.0 // indirect
github.com/theupdateframework/notary v0.7.0 // indirect
github.com/tonistiigi/fsutil v0.0.0-20220930225714-4638ad635be5 // indirect
github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea // indirect
Expand Down

0 comments on commit 6012946

Please sign in to comment.