Skip to content

Commit

Permalink
Fix unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
dreampuf committed May 27, 2023
1 parent b9f3c83 commit fba0b93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ png_in_bytes, box, _ := re.RenderAsPng(content)
`git clone https://github.com/dreampuf/mermaid.go.git`
2. Fetch the latest version of mermaid.js
`curl -LO https://unpkg.com/mermaid/dist/mermaid.min.js`
Or if you want a specific version
`curl -LO https://unpkg.com/[email protected]/dist/mermaid.min.js`
3. Test it
`go test ./...`

Expand Down
8 changes: 5 additions & 3 deletions mermaid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,16 @@ merge newbranch`},
for _, tt := range cases {
t.Run("", func(t *testing.T) {
got, err := re1.Render(tt.content)
t.Logf("got %s, error %s", got, err)
if err != nil {
if !strings.HasPrefix(err.Error(), tt.err_has_prefix) {
t.Errorf("Render() error = %v", err)
if strings.HasPrefix(err.Error(), tt.err_has_prefix) {
// expected exception
return
}
t.Errorf("Render() error = %v", err)
}
if !strings.HasPrefix(got, "<svg") {
t.Errorf("Render() got = %v", got)
t.Errorf("Render() got an invalid svg = %v, err = %s", got, err)
}

result_in_bytes, box, err := re1.RenderAsPng(tt.content)
Expand Down

0 comments on commit fba0b93

Please sign in to comment.