Skip to content

Commit

Permalink
fix(test): skip testing copy if xclip is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
musaubrian committed Jan 5, 2024
1 parent bdc4b0e commit 7e5e318
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/utils/pwd_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package utils_test

import (
"log"
"os/exec"
"strings"
"testing"

"github.com/atotto/clipboard"
Expand All @@ -17,6 +20,11 @@ func TestGeneratePassword(t *testing.T) {
}

func TestCopyToClipboard(t *testing.T) {
cmdRes, _ := exec.Command("xclip", "-h").CombinedOutput()
if !strings.Contains(string(cmdRes), "usage") {
log.Println("No utilities available for copying (x-clip)\n skipping test")
return
}
testStr := "This should be copied and retrieved from the clipboard"
err := utils.CopyToClipboard(testStr)
if err != nil {
Expand Down

0 comments on commit 7e5e318

Please sign in to comment.