Skip to content

Commit

Permalink
request_test: fix reload at the end of test, introduce -reload flag
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Jul 25, 2024
1 parent 44e3a40 commit 5102cdb
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions request_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package hyprland

import (
"flag"
"fmt"
"os"
"strings"
Expand All @@ -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++ {
Expand Down Expand Up @@ -52,17 +52,19 @@ 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())
}
}

func TestMain(m *testing.M) {
setup()
defer teardown()

exitCode := m.Run()

teardown()

os.Exit(exitCode)
}

Expand Down Expand Up @@ -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")
})
}

Expand All @@ -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)
}

Expand Down

0 comments on commit 5102cdb

Please sign in to comment.