-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Refactor site to improve testing (#2014)
It was difficult to develop this package due to the embed build tag being mandatory on the tests. The logic to test doesn't require any embedded files.
- Loading branch information
Showing
6 changed files
with
40 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//go:build embed | ||
// +build embed | ||
|
||
package site | ||
|
||
import ( | ||
"embed" | ||
"io/fs" | ||
) | ||
|
||
//go:embed out | ||
//go:embed out/bin/* | ||
var site embed.FS | ||
|
||
func FS() fs.FS { | ||
// the out directory is where webpack builds are created. It is in the same | ||
// directory as this file (package site). | ||
out, err := fs.Sub(site, "out") | ||
if err != nil { | ||
// This can't happen... Go would throw a compilation error. | ||
panic(err) | ||
} | ||
return out | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//go:build !embed | ||
// +build !embed | ||
|
||
package site | ||
|
||
import ( | ||
"embed" | ||
"io/fs" | ||
) | ||
|
||
var slim embed.FS | ||
|
||
func FS() fs.FS { | ||
return slim | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
//go:build embed | ||
// +build embed | ||
|
||
package site_test | ||
|
||
import ( | ||
|