Skip to content

Commit

Permalink
mr/issue: Test (un)subscribe commands
Browse files Browse the repository at this point in the history
  • Loading branch information
fmuellner committed Feb 25, 2021
1 parent 42e92b9 commit 1713610
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 0 deletions.
60 changes: 60 additions & 0 deletions cmd/issue_subscribe_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package cmd

import (
"os/exec"
"testing"

"github.com/acarl005/stripansi"
"github.com/stretchr/testify/require"
)

func Test_issueSubscribeSetup(t *testing.T) {
repo := copyTestRepo(t)
orig := exec.Command(labBinaryPath, "issue", "show", "1")
orig.Dir = repo

b, err := orig.CombinedOutput()
if err != nil {
t.Log(string(b))
t.Error(err)
}

origOutput := string(b)
origOutput = stripansi.Strip(origOutput)

require.Contains(t, origOutput, `Subscribed: No`)
}

func Test_issueSubscribe(t *testing.T) {
repo := copyTestRepo(t)
orig := exec.Command(labBinaryPath, "issue", "subscribe", "1")
orig.Dir = repo

b, err := orig.CombinedOutput()
if err != nil {
t.Log(string(b))
t.Error(err)
}

origOutput := string(b)
origOutput = stripansi.Strip(origOutput)

require.Contains(t, origOutput, `Subscribed to issue #1`)
}

func Test_issueUnsubscribe(t *testing.T) {
repo := copyTestRepo(t)
orig := exec.Command(labBinaryPath, "issue", "unsubscribe", "1")
orig.Dir = repo

b, err := orig.CombinedOutput()
if err != nil {
t.Log(string(b))
t.Error(err)
}

origOutput := string(b)
origOutput = stripansi.Strip(origOutput)

require.Contains(t, origOutput, `Unsubscribed from issue #1`)
}
63 changes: 63 additions & 0 deletions cmd/mr_subscribe_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package cmd

import (
"os/exec"
"testing"

"github.com/acarl005/stripansi"
"github.com/stretchr/testify/require"
)

// https://gitlab.com/zaquestion/test/-/merge_requests/18 was opened for these
// tests

func Test_mrSubscribeSetup(t *testing.T) {
repo := copyTestRepo(t)
orig := exec.Command(labBinaryPath, "mr", "show", "18")
orig.Dir = repo

b, err := orig.CombinedOutput()
if err != nil {
t.Log(string(b))
t.Error(err)
}

origOutput := string(b)
origOutput = stripansi.Strip(origOutput)

require.Contains(t, origOutput, `Subscribed: No`)
}

func Test_mrSubscribe(t *testing.T) {
repo := copyTestRepo(t)
orig := exec.Command(labBinaryPath, "mr", "subscribe", "18")
orig.Dir = repo

b, err := orig.CombinedOutput()
if err != nil {
t.Log(string(b))
t.Error(err)
}

origOutput := string(b)
origOutput = stripansi.Strip(origOutput)

require.Contains(t, origOutput, `Subscribed to merge request !18`)
}

func Test_mrUnsubscribe(t *testing.T) {
repo := copyTestRepo(t)
orig := exec.Command(labBinaryPath, "mr", "unsubscribe", "18")
orig.Dir = repo

b, err := orig.CombinedOutput()
if err != nil {
t.Log(string(b))
t.Error(err)
}

origOutput := string(b)
origOutput = stripansi.Strip(origOutput)

require.Contains(t, origOutput, `Unsubscribed from merge request !18`)
}

0 comments on commit 1713610

Please sign in to comment.