Skip to content

Commit 8d30295

Browse files
committed
Merge branch 'polyglot-go'
2 parents 89c5a7a + 3da28da commit 8d30295

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

.github/workflows/test.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,10 @@ jobs:
2626

2727
- name: Test on ${{ matrix.os }} with python ${{ matrix.python-version }}
2828
run: uv run --python ${{ matrix.python-version }} --managed-python pytest
29+
30+
- uses: actions/setup-go@v5
31+
with:
32+
go-version: stable
33+
34+
- name: Test Go
35+
run: go test ./...

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/Bing-su/stopments
2+
3+
go 1.23

stopment.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package stopment
2+
3+
import (
4+
"embed"
5+
"io/fs"
6+
)
7+
8+
//go:embed src/stopments/static
9+
var files embed.FS
10+
11+
// Static is a io/fs directory containing static files for the Stopments application.
12+
// It contains following files:
13+
//
14+
// - favicon.ico
15+
// - styles.min.css
16+
// - web-components.min.js
17+
// - scalar-api-reference.js
18+
var Static, _ = fs.Sub(files, "src/stopments/static")
19+
20+
var Favicon, _ = files.ReadFile("src/stopments/static/favicon.ico")
21+
var Styles, _ = files.ReadFile("src/stopments/static/styles.min.css")
22+
var WebComponents, _ = files.ReadFile("src/stopments/static/web-components.min.js")
23+
var ScalarApiReference, _ = files.ReadFile("src/stopments/static/scalar-api-reference.js")

stopment_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package stopment
2+
3+
import (
4+
"io/fs"
5+
"testing"
6+
)
7+
8+
func TestStaticFS(t *testing.T) {
9+
entries, err := fs.ReadDir(Static, ".")
10+
if err != nil {
11+
t.Fatalf("failed to read static dir: %v", err)
12+
}
13+
files := map[string]bool{}
14+
for _, entry := range entries {
15+
files[entry.Name()] = true
16+
}
17+
for _, name := range []string{"favicon.ico", "styles.min.css", "web-components.min.js", "scalar-api-reference.js"} {
18+
if !files[name] {
19+
t.Errorf("missing static file: %s", name)
20+
}
21+
}
22+
}
23+
24+
func TestStaticFilesContent(t *testing.T) {
25+
if len(Favicon) == 0 {
26+
t.Error("Favicon is empty")
27+
}
28+
if len(Styles) == 0 {
29+
t.Error("Styles is empty")
30+
}
31+
if len(WebComponents) == 0 {
32+
t.Error("WebComponents is empty")
33+
}
34+
if len(ScalarApiReference) == 0 {
35+
t.Error("ScalarApiReference is empty")
36+
}
37+
}

0 commit comments

Comments
 (0)