From 19f17308b1eaac05ac525fdd31aa68b069507f3b Mon Sep 17 00:00:00 2001 From: Urko Date: Sun, 26 Feb 2023 16:07:14 +0100 Subject: [PATCH] feat: test pkg watcher --- pkg/watcher/test-script.sh | 2 ++ pkg/watcher/watcher_test.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 pkg/watcher/test-script.sh create mode 100644 pkg/watcher/watcher_test.go diff --git a/pkg/watcher/test-script.sh b/pkg/watcher/test-script.sh new file mode 100644 index 0000000..57ac3b2 --- /dev/null +++ b/pkg/watcher/test-script.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo "hello" \ No newline at end of file diff --git a/pkg/watcher/watcher_test.go b/pkg/watcher/watcher_test.go new file mode 100644 index 0000000..6bbb85d --- /dev/null +++ b/pkg/watcher/watcher_test.go @@ -0,0 +1,32 @@ +package watcher + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +var ( + binaryPath = "/bin/bash" + scriptPath = "./test-script.sh" +) + +func TestDeploy(t *testing.T) { + err := Deploy(binaryPath, scriptPath) + require.NoError(t, err) +} + +func TestDeployError(t *testing.T) { + err := Deploy("", "") + require.Error(t, err) +} + +func TestExecute(t *testing.T) { + err := execute(binaryPath, scriptPath) + require.NoError(t, err) +} + +func TestExecuteError(t *testing.T) { + err := execute("", "") + require.Error(t, err) +}