Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
thampiotr committed Nov 17, 2023
1 parent 72d6d08 commit 3f293c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions docs/docs_updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ func runForGenerator(t *testing.T, g generator.DocsGenerator) {
require.NoError(t, err, "failed to generate: %q", g.Name())

if generated == "" {
t.Skipf("nothing generated for %q, skipping", g.Name())
actual, err := g.Read()
require.Error(t, err, "expected error when reading existing generated docs for %q", g.Name())
require.Contains(t, err.Error(), "markers not found", "expected error to be about missing markers")
require.Empty(t, actual, "expected empty actual content for %q", g.Name())
return
}

if *fixTestsFlag {
if *fixTestsFlag && generated != "" {
err = g.Write()
require.NoError(t, err, "failed to write generated content for: %q", g.Name())
t.Log("updated the docs with generated content", g.Name())
Expand Down
2 changes: 1 addition & 1 deletion docs/generator/docs_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func readBetweenMarkers(startMarker string, endMarker string, filePath string) (
startIndex := bytes.Index(fileContents, []byte(startMarker))
endIndex := bytes.LastIndex(fileContents, []byte(endMarker))
if startIndex == -1 || endIndex == -1 {
return "", fmt.Errorf("markers %q or %q not found", startMarker, endMarker)
return "", fmt.Errorf("markers not found: %q or %q", startMarker, endMarker)
}

return string(fileContents[startIndex+len(startMarker) : endIndex]), nil
Expand Down

0 comments on commit 3f293c0

Please sign in to comment.