Skip to content

Commit

Permalink
Fix existing tests (still missing new ones)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Shkuro <[email protected]>
  • Loading branch information
Yuri Shkuro committed Oct 24, 2017
1 parent 3758253 commit cb878e2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
14 changes: 10 additions & 4 deletions cmd/query/app/builder/builder_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ import (

func TestQueryBuilderFlags(t *testing.T) {
v, command := config.Viperize(AddFlags)
command.ParseFlags([]string{"--query.static-files=/dev/null", "--query.prefix=api", "--query.port=80"})
command.ParseFlags([]string{
"--query.static-files=/dev/null",
"--query.ui-config=some.json",
"--query.prefix=api",
"--query.port=80",
})
qOpts := new(QueryOptions).InitFromViper(v)
assert.Equal(t, "/dev/null", qOpts.QueryStaticAssets)
assert.Equal(t, "api", qOpts.QueryPrefix)
assert.Equal(t, 80, qOpts.QueryPort)
assert.Equal(t, "/dev/null", qOpts.StaticAssets)
assert.Equal(t, "some.json", qOpts.UIConfig)
assert.Equal(t, "api", qOpts.Prefix)
assert.Equal(t, 80, qOpts.Port)
}
2 changes: 1 addition & 1 deletion cmd/query/app/static_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func NewStaticAssetsHandler(staticAssetsRoot string, uiConfig string) (*StaticAs
}
indexBytes, err := ioutil.ReadFile(staticAssetsRoot + "index.html")
if err != nil {
return nil, errors.Wrap(err, "Cannot read index.html from UI static assets")
return nil, errors.Wrap(err, "Cannot read UI static assets")
}
configString := "JAEGER_CONFIG = DEFAULT_CONFIG;"
if config, err := loadUIConfig(uiConfig); err != nil {
Expand Down
10 changes: 6 additions & 4 deletions cmd/query/app/static_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import (

func TestStaticAssetsHandler(t *testing.T) {
r := mux.NewRouter()
handler := NewStaticAssetsHandler("fixture")
handler, err := NewStaticAssetsHandler("fixture", "")
require.NoError(t, err)
handler.RegisterRoutes(r)
server := httptest.NewServer(r)
defer server.Close()
Expand All @@ -45,13 +46,14 @@ func TestStaticAssetsHandler(t *testing.T) {
}

func TestDefaultStaticAssetsRoot(t *testing.T) {
handler := NewStaticAssetsHandler("")
assert.Equal(t, "jaeger-ui-build/build/", handler.staticAssetsRoot)
_, err := NewStaticAssetsHandler("", "")
assert.EqualError(t, err, "Cannot read UI static assets: open jaeger-ui-build/build/index.html: no such file or directory")
}

func TestRegisterRoutesHandler(t *testing.T) {
r := mux.NewRouter()
handler := NewStaticAssetsHandler("fixture/")
handler, err := NewStaticAssetsHandler("fixture/", "")
require.NoError(t, err)
handler.RegisterRoutes(r)
server := httptest.NewServer(r)
defer server.Close()
Expand Down

0 comments on commit cb878e2

Please sign in to comment.