From 6bc9ec79f0b31a561662838e44478cfe65d0751b Mon Sep 17 00:00:00 2001 From: Kenta Yamamoto Date: Tue, 12 Feb 2019 22:58:41 +0900 Subject: [PATCH] Changed test package names --- al2/commands_test.go | 5 +++-- al2/service_test.go | 7 ++++--- al2/web/albert_sites_test.go | 15 ++++++++------- al2/web/alfred_sites_test.go | 15 ++++++++------- al2/web/config_dict_test.go | 9 +++++---- al2/web/launcher_test.go | 17 +++++++++-------- al2/web/pair_test.go | 19 ++++++++++--------- al2/web/site_config_test.go | 11 ++++++----- al2/web/web_test.go | 13 +++++++------ 9 files changed, 60 insertions(+), 51 deletions(-) diff --git a/al2/commands_test.go b/al2/commands_test.go index 930663b..097661c 100644 --- a/al2/commands_test.go +++ b/al2/commands_test.go @@ -1,9 +1,10 @@ -package al2 +package al2_test import ( "flag" "github.com/ToQoz/gopwt" "github.com/ToQoz/gopwt/assert" + "github.com/announce/altogether/al2" "github.com/announce/altogether/al2/helper" "os" "testing" @@ -17,5 +18,5 @@ func TestMain(m *testing.M) { } func TestCommands(t *testing.T) { - assert.OK(t, Commands != nil) + assert.OK(t, al2.Commands != nil) } diff --git a/al2/service_test.go b/al2/service_test.go index 81d7710..d208a88 100644 --- a/al2/service_test.go +++ b/al2/service_test.go @@ -1,8 +1,9 @@ -package al2 +package al2_test import ( "bytes" "github.com/ToQoz/gopwt/assert" + "github.com/announce/altogether/al2" "github.com/announce/altogether/al2/domain" "github.com/announce/altogether/al2/helper" "github.com/announce/altogether/al2/web" @@ -13,10 +14,10 @@ func TestHandler_Perform(t *testing.T) { defer helper.MustRemoveTmpDir() out := bytes.Buffer{} errOut := out - h := &Handler{ + h := &al2.Handler{ AlfredPath: helper.EnsureDataPath(domain.Alfred, web.Config), AlbertPath: helper.EnsureDataPath(domain.Albert, web.Config), - Mode: &Mode{ + Mode: &al2.Mode{ DryRun: true, Verbose: false, }, diff --git a/al2/web/albert_sites_test.go b/al2/web/albert_sites_test.go index f20c68f..3ccaf82 100644 --- a/al2/web/albert_sites_test.go +++ b/al2/web/albert_sites_test.go @@ -1,15 +1,16 @@ -package web +package web_test import ( "bytes" "github.com/ToQoz/gopwt/assert" + "github.com/announce/altogether/al2/web" "github.com/google/uuid" "strings" "testing" ) -func newAlbertConfigDict() ConfigDict { - c1 := &SiteConfig{ +func newAlbertConfigDict() web.ConfigDict { + c1 := &web.SiteConfig{ Uuid: strings.ToUpper(uuid.New().String()), Enabled: true, Utf8: true, @@ -17,7 +18,7 @@ func newAlbertConfigDict() ConfigDict { Name: "Sample description", Url: "https://foo.example.com/{query}/", } - c2 := &SiteConfig{ + c2 := &web.SiteConfig{ Uuid: strings.ToUpper(uuid.New().String()), Enabled: true, Utf8: true, @@ -25,7 +26,7 @@ func newAlbertConfigDict() ConfigDict { Name: "Sample description", Url: "https://bar.example.com/{query}/", } - dict := make(ConfigDict) + dict := make(web.ConfigDict) dict[c1.Id()] = c1 dict[c2.Id()] = c2 return dict @@ -33,7 +34,7 @@ func newAlbertConfigDict() ConfigDict { func TestAlbertSites_Encode(t *testing.T) { dict := newAlbertConfigDict() - sites := AlbertSites{} + sites := web.AlbertSites{} json, err := sites.Encode(dict) assert.OK(t, json != nil) assert.OK(t, len(json) > 0) @@ -42,7 +43,7 @@ func TestAlbertSites_Encode(t *testing.T) { func TestAlbertSites_Decode(t *testing.T) { dict := newAlbertConfigDict() - sites := AlbertSites{} + sites := web.AlbertSites{} json, _ := sites.Encode(dict) data := bytes.NewReader(json) err := sites.Decode(data) diff --git a/al2/web/alfred_sites_test.go b/al2/web/alfred_sites_test.go index 6db89e8..627fd5e 100644 --- a/al2/web/alfred_sites_test.go +++ b/al2/web/alfred_sites_test.go @@ -1,15 +1,16 @@ -package web +package web_test import ( "bytes" "github.com/ToQoz/gopwt/assert" + "github.com/announce/altogether/al2/web" "github.com/google/uuid" "strings" "testing" ) -func newAlfredConfigDict() ConfigDict { - c1 := &SiteConfig{ +func newAlfredConfigDict() web.ConfigDict { + c1 := &web.SiteConfig{ Uuid: strings.ToUpper(uuid.New().String()), Enabled: true, Utf8: true, @@ -17,12 +18,12 @@ func newAlfredConfigDict() ConfigDict { Name: "Sample description", Url: "https://foo.example.com/%s/", } - c2 := &SiteConfig{ + c2 := &web.SiteConfig{ Trigger: "bar ", Name: "Sample description", Url: "https://bar.example.com/%s/", } - dict := make(ConfigDict) + dict := make(web.ConfigDict) dict[c1.Id()] = c1 dict[c2.Id()] = c2 return dict @@ -30,7 +31,7 @@ func newAlfredConfigDict() ConfigDict { func TestAlfredSites_Encode(t *testing.T) { dict := newAlfredConfigDict() - sites := &AlfredSites{} + sites := &web.AlfredSites{} json, err := sites.Encode(dict) assert.OK(t, json != nil) assert.OK(t, len(json) > 0) @@ -39,7 +40,7 @@ func TestAlfredSites_Encode(t *testing.T) { func TestAlfredSites_Decode(t *testing.T) { dict := newAlfredConfigDict() - sites := &AlfredSites{} + sites := &web.AlfredSites{} plist, _ := sites.Encode(dict) data := bytes.NewReader(plist) err := sites.Decode(data) diff --git a/al2/web/config_dict_test.go b/al2/web/config_dict_test.go index 25570a8..48735f8 100644 --- a/al2/web/config_dict_test.go +++ b/al2/web/config_dict_test.go @@ -1,18 +1,19 @@ -package web +package web_test import ( "crypto/sha1" "fmt" "github.com/ToQoz/gopwt/assert" + "github.com/announce/altogether/al2/web" "strings" "testing" ) func TestConfigDict_String(t *testing.T) { - dict := make(ConfigDict) + dict := make(web.ConfigDict) assert.OK(t, len(fmt.Sprintf("%s", dict)) == 0) - dict[sha1.Sum([]byte("a"))] = &SiteConfig{} + dict[sha1.Sum([]byte("a"))] = &web.SiteConfig{} assert.OK(t, strings.Count(dict.String(), "\n") == 0) - dict[sha1.Sum([]byte("b"))] = &SiteConfig{} + dict[sha1.Sum([]byte("b"))] = &web.SiteConfig{} assert.OK(t, strings.Count(dict.String(), "\n") == 1) } diff --git a/al2/web/launcher_test.go b/al2/web/launcher_test.go index 1fb5f27..e42144e 100644 --- a/al2/web/launcher_test.go +++ b/al2/web/launcher_test.go @@ -1,16 +1,17 @@ -package web +package web_test import ( "github.com/ToQoz/gopwt/assert" "github.com/announce/altogether/al2/domain" "github.com/announce/altogether/al2/helper" + "github.com/announce/altogether/al2/web" "testing" ) -func newLauncher(p domain.Type) *Launcher { - launcher := &Launcher{ +func newLauncher(p domain.Type) *web.Launcher { + launcher := &web.Launcher{ Type: p, - BasePath: helper.EnsureDataPath(p, Config), + BasePath: helper.EnsureDataPath(p, web.Config), } launcher.Init() return launcher @@ -53,14 +54,14 @@ func TestLauncher_Parse(t *testing.T) { func TestLauncher_Populate(t *testing.T) { defer helper.MustRemoveTmpDir() t.Run("it works with Alfred", func(t *testing.T) { - dict := make(ConfigDict) + dict := make(web.ConfigDict) launcher := newLauncher(domain.Alfred) _ = launcher.Parse() launcher.Populate(dict) assert.OK(t, len(dict) > 0) }) t.Run("it works with Albert", func(t *testing.T) { - dict := make(ConfigDict) + dict := make(web.ConfigDict) launcher := newLauncher(domain.Albert) _ = launcher.Parse() launcher.Populate(dict) @@ -71,7 +72,7 @@ func TestLauncher_Populate(t *testing.T) { func TestLauncher_Save(t *testing.T) { defer helper.MustRemoveTmpDir() t.Run("it works with Alfred", func(t *testing.T) { - dict := make(ConfigDict) + dict := make(web.ConfigDict) launcher := newLauncher(domain.Alfred) _ = launcher.Load() _ = launcher.Parse() @@ -80,7 +81,7 @@ func TestLauncher_Save(t *testing.T) { assert.OK(t, err == nil) }) t.Run("it works with Albert", func(t *testing.T) { - dict := make(ConfigDict) + dict := make(web.ConfigDict) launcher := newLauncher(domain.Albert) _ = launcher.Load() _ = launcher.Parse() diff --git a/al2/web/pair_test.go b/al2/web/pair_test.go index 886e8e6..c78ee95 100644 --- a/al2/web/pair_test.go +++ b/al2/web/pair_test.go @@ -1,22 +1,23 @@ -package web +package web_test import ( "github.com/ToQoz/gopwt/assert" "github.com/announce/altogether/al2/domain" "github.com/announce/altogether/al2/helper" + "github.com/announce/altogether/al2/web" "testing" "time" ) -func newPair() (*Pair, error) { - pair := &Pair{ - &Launcher{ +func newPair() (*web.Pair, error) { + pair := &web.Pair{ + &web.Launcher{ Type: domain.Alfred, - BasePath: helper.EnsureDataPath(domain.Alfred, Config), + BasePath: helper.EnsureDataPath(domain.Alfred, web.Config), }, - &Launcher{ + &web.Launcher{ Type: domain.Albert, - BasePath: helper.EnsureDataPath(domain.Albert, Config), + BasePath: helper.EnsureDataPath(domain.Albert, web.Config), }} return pair, pair.Load() } @@ -35,7 +36,7 @@ func TestPair_Merge(t *testing.T) { helper.MustTouchFile(path0, 0) helper.MustTouchFile(path1, 1*time.Nanosecond) _ = pair.Load() - pair.Merge(make(ConfigDict)) + pair.Merge(make(web.ConfigDict)) assert.OK(t, pair[0].ConfigPath == path0) assert.OK(t, pair[1].ConfigPath == path1) }) @@ -45,7 +46,7 @@ func TestPair_Merge(t *testing.T) { helper.MustTouchFile(path1, 0) helper.MustTouchFile(path0, 1*time.Nanosecond) _ = pair.Load() - pair.Merge(make(ConfigDict)) + pair.Merge(make(web.ConfigDict)) //log.Printf("(p1, p1)=(%v,%v)(%v, %v)", // pair[0].Type, pair[1].Type, pair[0].Mtime(), pair[1].Mtime()) assert.OK(t, pair[1].ConfigPath == path0) diff --git a/al2/web/site_config_test.go b/al2/web/site_config_test.go index e97650d..f3aad72 100644 --- a/al2/web/site_config_test.go +++ b/al2/web/site_config_test.go @@ -1,20 +1,21 @@ -package web +package web_test import ( "encoding/hex" "github.com/ToQoz/gopwt/assert" "github.com/announce/altogether/al2/domain" + "github.com/announce/altogether/al2/web" "github.com/google/uuid" "strings" "testing" ) -func newSiteConfig(p domain.Type) *SiteConfig { - config := &SiteConfig{} +func newSiteConfig(p domain.Type) *web.SiteConfig { + config := &web.SiteConfig{} switch p { case domain.Alfred: { - config = &SiteConfig{ + config = &web.SiteConfig{ Uuid: strings.ToUpper(uuid.New().String()), Enabled: true, Utf8: true, @@ -25,7 +26,7 @@ func newSiteConfig(p domain.Type) *SiteConfig { } case domain.Albert: { - config = &SiteConfig{ + config = &web.SiteConfig{ Trigger: "jj ", Name: "Sample description", Url: "https://example.com/%s/", diff --git a/al2/web/web_test.go b/al2/web/web_test.go index 0cad8bc..9b00823 100644 --- a/al2/web/web_test.go +++ b/al2/web/web_test.go @@ -1,4 +1,4 @@ -package web +package web_test import ( "bytes" @@ -6,6 +6,7 @@ import ( "github.com/ToQoz/gopwt" "github.com/ToQoz/gopwt/assert" "github.com/announce/altogether/al2/helper" + "github.com/announce/altogether/al2/web" "os" "strings" "testing" @@ -23,19 +24,19 @@ func TestWeb_Sync(t *testing.T) { out := bytes.Buffer{} errOut := out pair, _ := newPair() - web := Web{ + w := web.Web{ Launchers: pair, Out: &out, ErrOut: &errOut, } t.Run("it works with no dry-run option", func(t *testing.T) { - err := web.Sync(Option{DtyRun: false, Verbose: false}) + err := w.Sync(web.Option{DtyRun: false, Verbose: false}) assert.OK(t, err == nil) - assert.OK(t, web.ConfigDict != nil) + assert.OK(t, w.ConfigDict != nil) }) t.Run("it works with dry-run option", func(t *testing.T) { - err := web.Sync(Option{DtyRun: true, Verbose: true}) + err := w.Sync(web.Option{DtyRun: true, Verbose: true}) assert.OK(t, err == nil) - assert.OK(t, strings.Count(out.String(), "\n") == len(web.ConfigDict)) + assert.OK(t, strings.Count(out.String(), "\n") == len(w.ConfigDict)) }) }