From c57ed7cc0b72604221eb0c91637c42fac828b064 Mon Sep 17 00:00:00 2001 From: alok Date: Tue, 14 Dec 2021 17:17:47 +0530 Subject: [PATCH] fix: increase coverage --- modules/repo/fsrepo/fsrepo_test.go | 30 ++++++++++++++++++------------ modules/repo/inmem/inmem_test.go | 24 ++++++++++++++++++++++++ msuite_test.go | 1 + 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/modules/repo/fsrepo/fsrepo_test.go b/modules/repo/fsrepo/fsrepo_test.go index e38e97e..3e0b1a9 100644 --- a/modules/repo/fsrepo/fsrepo_test.go +++ b/modules/repo/fsrepo/fsrepo_test.go @@ -124,23 +124,29 @@ func TestRepo(t *testing.T) { t.Fatal("expected to find mounted datastore") } + verifyMounts := func(mnts []fsrepo.MountInfo) { + if len(mnts) != 2 { + t.Fatal("expected 2 mounts found", len(mnts)) + } + + for _, v := range mnts { + if v.Path != ".testrepo/kv" && v.Path != ".testrepo/blocks" { + t.Fatal("unexpected paths", v.Path) + } + if v.Prefix != "/" && v.Prefix != "/blocks" { + t.Fatal("unexpected prefixes", v.Prefix) + } + } + } + mntInfo, err := mds.Mounts() if err != nil { t.Fatal(err) } + verifyMounts(mntInfo) - if len(mntInfo) != 2 { - t.Fatal("expected 2 mounts found", len(mntInfo)) - } - - for _, v := range mntInfo { - if v.Path != ".testrepo/kv" && v.Path != ".testrepo/blocks" { - t.Fatal("unexpected paths", v.Path) - } - if v.Prefix != "/" && v.Prefix != "/blocks" { - t.Fatal("unexpected prefixes", v.Prefix) - } - } + mntInfo2 := r.Status().(map[string]interface{})["On-disk Mounts"].([]fsrepo.MountInfo) + verifyMounts(mntInfo2) cfg.Set("TestAdd", "some value") err = r.SetConfig(cfg) diff --git a/modules/repo/inmem/inmem_test.go b/modules/repo/inmem/inmem_test.go index 45a0ca6..b9a1c1d 100644 --- a/modules/repo/inmem/inmem_test.go +++ b/modules/repo/inmem/inmem_test.go @@ -15,6 +15,18 @@ func TestInmemRepo(t *testing.T) { t.Fatal(err) } + if r.Datastore() == nil { + t.Fatal("datastore not found") + } + + if r.Store() == nil { + t.Fatal("store not found") + } + + if r.Status().(string) != "In-mem repository" { + t.Fatal("invalid status") + } + err = r.Close() if err != nil { t.Fatal(err) @@ -50,6 +62,18 @@ func TestInmemRepo(t *testing.T) { t.Fatal("expected config to be different") } + if r.Datastore() == nil { + t.Fatal("datastore not found") + } + + if r.Store() == nil { + t.Fatal("store not found") + } + + if r.Status().(string) != "In-mem repository" { + t.Fatal("invalid status") + } + err = r.Close() if err != nil { t.Fatal(err) diff --git a/msuite_test.go b/msuite_test.go index 5f45789..51305b0 100644 --- a/msuite_test.go +++ b/msuite_test.go @@ -383,6 +383,7 @@ func TestServices(t *testing.T) { msuite.WithGRPCTCPListener(10000), msuite.WithHTTP(10001), msuite.WithPrometheus(true), + msuite.WithDebug(), msuite.WithStaticDiscovery(map[string]string{ "svc1": "IP1", "svc2": "IP2",