common/embed: check which interfaces are implemented
Some checks failed
CI / 🤖 Check dependabot status (push) Has been cancelled
CI / 🐧 Test on Linux (${{ github.ref_type == 'tag' }}, misc) (push) Has been cancelled
CI / 🐧 Test on Linux (coverage) (push) Has been cancelled
CI / 🐧 Test on Linux (regular) (push) Has been cancelled
CI / ❄️ Build on Nix (push) Has been cancelled
CI / 🍏 Build and test on macOS (push) Has been cancelled
CI / 🧪 End-to-end testing (push) Has been cancelled
CI / 🔍 Upload code coverage (push) Has been cancelled
CI / 🔬 Test only Go (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 20) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 22) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 24) (push) Has been cancelled
CI / ⚖️ Check licenses (push) Has been cancelled
CI / 🐋 Build Docker images (push) Has been cancelled
CI / 🐋 Tag Docker images (push) Has been cancelled
CI / 🚀 Publish release (push) Has been cancelled
Update Nix dependency hashes / Update dependency hashes (push) Has been cancelled
Update Nix flake.lock / Update Nix lockfile (asn2org) (push) Has been cancelled
Update Nix flake.lock / Update Nix lockfile (iana-assignments) (push) Has been cancelled
Update Nix flake.lock / Update Nix lockfile (nixpkgs) (push) Has been cancelled

This commit is contained in:
Vincent Bernat
2025-12-07 11:35:16 +01:00
parent 84bd9a6464
commit b4306375e5

View File

@@ -6,6 +6,7 @@ package embed
import (
_ "embed"
"io"
"io/fs"
"testing"
"akvorado/common/helpers"
@@ -30,6 +31,30 @@ func TestData(t *testing.T) {
if diff := helpers.Diff(string(got), expected); diff != "" {
t.Fatalf("ReadFull() (-got, +want):\n%s", diff)
}
// Small checks for interfaces
if _, ok := f.(io.Reader); !ok {
t.Fatal("f does not implement io.Reader")
}
if _, ok := f.(io.ReadCloser); !ok {
t.Fatal("f does not implement io.ReadCloser")
}
// Currently, this is not true, but this may become one day!
if _, ok := f.(fs.ReadDirFS); ok {
t.Error("f implements fs.ReadDirFS!")
}
if _, ok := f.(fs.ReadDirFile); ok {
t.Error("f implements fs.ReadDirFile!")
}
if _, ok := f.(fs.SubFS); ok {
t.Error("f implements fs.SubFS!")
}
if _, ok := f.(io.ReaderAt); ok {
t.Error("f implements io.ReaderAt!")
}
if _, ok := f.(io.Seeker); ok {
t.Error("f implements io.Seeker!")
}
}
func BenchmarkData(b *testing.B) {