Skip to content

Commit

Permalink
Add Test For Actual Present Case
Browse files Browse the repository at this point in the history
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
mahadzaryab1 committed Sep 2, 2024
1 parent 331536d commit 7551104
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmd/query/app/ui/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/jaegertracing/jaeger/cmd/query/app/ui/testdata"
"github.com/jaegertracing/jaeger/pkg/testutils"
)

Expand All @@ -29,3 +30,20 @@ func TestGetStaticFiles_ReturnsPlaceholderWhenActualNotPresent(t *testing.T) {
require.Contains(t, string(bytes), "This is a placeholder for the Jaeger UI home page")
require.Contains(t, logBuf.String(), "ui assets not embedded in the binary, using a placeholder")
}

func TestGetStaticFiles_ReturnsActualWhenPresent(t *testing.T) {
// swap out the assets FS for an dummy one and then replace it back when the
// test completes
currentActualAssets := actualAssetsFS
actualAssetsFS = testdata.TestFS
t.Cleanup(func() { actualAssetsFS = currentActualAssets })

logger, logBuf := testutils.NewLogger()
fs := GetStaticFiles(logger)
file, err := fs.Open("/index.html")
require.NoError(t, err)
bytes, err := io.ReadAll(file)
require.NoError(t, err)
require.NotContains(t, string(bytes), "This is a placeholder for the Jaeger UI home page")
require.NotContains(t, logBuf.String(), "ui assets not embedded in the binary, using a placeholder")
}
Binary file added cmd/query/app/ui/testdata/actual/index.html.gz
Binary file not shown.
6 changes: 6 additions & 0 deletions cmd/query/app/ui/testdata/mock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package testdata

import "embed"

//go:embed actual/*
var TestFS embed.FS

0 comments on commit 7551104

Please sign in to comment.