Skip to content

Commit a140554

Browse files
committed
. t add hello world test and snippet
1 parent 171d509 commit a140554

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed

.github/workflows/updateMarkdown.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717
- name: Run MarkdownSnippets
18-
run: |
19-
dotnet tool install --global MarkdownSnippets.Tool
20-
mdsnippets ${GITHUB_WORKSPACE}
21-
shell: bash
18+
run: run-md-snippets.sh
2219
- name: Git Commit and Push
2320
uses: github-actions-x/commit@v2.9
2421
with:

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ ApprovalTests allows for easy testing of larger objects, strings and anything el
2525
# Examples
2626
## Basic string verification
2727

28+
<!-- snippet: HelloWorld -->
29+
<a id='snippet-HelloWorld'></a>
2830
```go
2931
func TestHelloWorld(t *testing.T) {
3032
approvals.VerifyString(t, "Hello World!")
3133
}
3234
```
35+
<sup><a href='/documentation_examples_test.go#L9-L14' title='Snippet source file'>snippet source</a> | <a href='#snippet-HelloWorld' title='Start of snippet'>anchor</a></sup>
36+
<!-- endSnippet -->
3337

3438
## Store approved files in testdata subfolder
3539
Some people prefer to store their approved files in a subfolder "testdata" instead of in the same folder as the

documentation_examples_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package approvals_test
2+
3+
import (
4+
"testing"
5+
6+
approvals "github.com/approvals/go-approval-tests"
7+
)
8+
9+
// begin-snippet: HelloWorld
10+
func TestHelloWorld(t *testing.T) {
11+
approvals.VerifyString(t, "Hello World!")
12+
}
13+
14+
// end-snippet

run-md-snippets.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
dotnet tool install --global MarkdownSnippets.Tool
5+
mdsnippets .

run_tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
set -euo pipefail
23

34
go build -v ./...
45
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello World!

0 commit comments

Comments
 (0)