Skip to content

armgit / Piik

Public Imported from GitHub
0

Free, open-source screen sharing for private live streams with friends. Watch together in a browser or self-host Piik. 免费开源的私密屏幕共享,支持游戏直播、一起看电影与自部署。

1.0 KB
Raw Blame
package webassets

import (
	"io/fs"
	"testing"
)

// TestFSTracksIndexHTML holds whether or not a Vite build is present: FS() must
// be non-nil exactly when dist/index.html is embedded.
func TestFSTracksIndexHTML(t *testing.T) {
	_, err := fs.Stat(embedded, "dist/index.html")
	assets := FS()

	switch {
	case err == nil && assets == nil:
		t.Fatal("dist/index.html is embedded but FS() returned nil")
	case err != nil && assets != nil:
		t.Fatalf("dist/index.html is absent (%v) but FS() returned a file system", err)
	case assets == nil:
		t.Log("no build embedded: the app serves the API only")
		return
	}

	if _, err := fs.Stat(assets, "index.html"); err != nil {
		t.Fatalf("index.html is not reachable through FS(): %v", err)
	}
}

// TestGitkeepIsEmbedded pins the `all:` prefix: without it the package does not
// build on a checkout whose dist holds only the dot-prefixed marker.
func TestGitkeepIsEmbedded(t *testing.T) {
	if _, err := fs.Stat(embedded, "dist/.gitkeep"); err != nil {
		t.Fatalf("dist/.gitkeep must stay tracked and embedded: %v", err)
	}
}