From bfbf660cd1b41e0de9ea11a4296b4a94f31e0115 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 14 Mar 2014 12:08:43 -0700 Subject: [PATCH] serverinit: fix flaky test. sort publishRoot prefixes, for predictable output Change-Id: I230a7d344f9c982539b3ed6d3a88eb1066322ea5 --- pkg/serverinit/genconfig.go | 10 ++++++---- pkg/serverinit/testdata/multipublish-want.json | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/serverinit/genconfig.go b/pkg/serverinit/genconfig.go index bc2b3288c..a655907ff 100644 --- a/pkg/serverinit/genconfig.go +++ b/pkg/serverinit/genconfig.go @@ -22,6 +22,7 @@ import ( "net/url" "os" "path/filepath" + "sort" "strings" "camlistore.org/pkg/blob" @@ -52,8 +53,8 @@ var ( func addPublishedConfig(prefixes jsonconfig.Obj, published map[string]*serverconfig.Publish, - sourceRoot string) ([]interface{}, error) { - pubPrefixes := []interface{}{} + sourceRoot string) ([]string, error) { + var pubPrefixes []string for k, v := range published { name := strings.Replace(k, "/", "", -1) rootName := name + "Root" @@ -96,13 +97,14 @@ func addPublishedConfig(prefixes jsonconfig.Obj, prefixes[k] = ob pubPrefixes = append(pubPrefixes, k) } + sort.Strings(pubPrefixes) return pubPrefixes, nil } func addUIConfig(params *configPrefixesParams, prefixes jsonconfig.Obj, uiPrefix string, - published []interface{}, + published []string, sourceRoot string) { args := map[string]interface{}{ @@ -626,7 +628,7 @@ func genLowLevelConfig(conf *serverconfig.Config) (lowLevelConf *Config, err err } } - published := []interface{}{} + var published []string if len(conf.Publish) > 0 { if !runIndex { return nil, fmt.Errorf("publishing requires an index") diff --git a/pkg/serverinit/testdata/multipublish-want.json b/pkg/serverinit/testdata/multipublish-want.json index b05724f41..1c7755fe0 100644 --- a/pkg/serverinit/testdata/multipublish-want.json +++ b/pkg/serverinit/testdata/multipublish-want.json @@ -146,8 +146,8 @@ "cache": "/cache/", "jsonSignRoot": "/sighelper/", "publishRoots": [ - "/pics/", - "/music/" + "/music/", + "/pics/" ], "scaledImage": { "file": "/tmp/blobs/thumbmeta.kv",