From 5102cdba32f213c6bd0d4982bbc615832ee8446e Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 25 Jul 2024 17:11:16 +0100 Subject: [PATCH] request_test: fix reload at the end of test, introduce -reload flag --- request_test.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/request_test.go b/request_test.go index 670fc88..7f35ace 100644 --- a/request_test.go +++ b/request_test.go @@ -1,6 +1,7 @@ package hyprland import ( + "flag" "fmt" "os" "strings" @@ -10,11 +11,10 @@ import ( "github.com/thiagokokada/hyprland-go/internal/assert" ) -var c *RequestClient - -type DummyClient struct { - RequestClient -} +var ( + c *RequestClient + reload = flag.Bool("reload", true, "reload configuration after tests end") +) func genParams(param string, n int) (params []string) { for i := 0; i < n; i++ { @@ -52,7 +52,7 @@ func setup() { } func teardown() { - if c != nil { + if *reload && c != nil { // Make sure that the Hyprland config is in a sane state assert.Must1(c.Reload()) } @@ -60,9 +60,11 @@ func teardown() { func TestMain(m *testing.M) { setup() - defer teardown() exitCode := m.Run() + + teardown() + os.Exit(exitCode) } @@ -314,7 +316,7 @@ func TestGetOption(t *testing.T) { func TestKeyword(t *testing.T) { testCommandRs(t, func() ([]Response, error) { - return c.Keyword("general:border_size 1", "general:border_size 5") + return c.Keyword("bind SUPER,K,exec,kitty", "general:border_size 5") }) } @@ -334,6 +336,9 @@ func TestMonitors(t *testing.T) { } func TestReload(t *testing.T) { + if testing.Short() { + t.Skip("skip test that reload config") + } testCommandR(t, c.Reload) }