Skip to content

Commit

Permalink
fixed integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: gauron99 <fridrich.david19@gmail.com>
  • Loading branch information
gauron99 committed Mar 20, 2024
1 parent 24ed28b commit f030066
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions pkg/functions/client_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"net/http"
"os"
"path"
"path/filepath"
"reflect"
"testing"
Expand Down Expand Up @@ -291,6 +292,53 @@ func TestUpdateWithAnnotationsAndLabels(t *testing.T) {
}
}

// TestBuildWithoutHome ensures that running func without HOME fails for pack builder
func TestBuildWithoutHome(t *testing.T) {
root, cleanup := Mktemp(t)
defer cleanup()
t.Setenv("HOME", "")
verbose := true

f := fn.Function{Runtime: "go", Name: "test-deploy-without-home", Root: root}
client := newClient(verbose)
if _, err := client.Build(context.Background(), f); err == nil {
t.Fatalf("expected an error for HOME not defined with pack builder, got none")
}

// dont call del() because function wasnt deployed
}

// TestDeployWithoutWritableDotConfig ensures that running client.New works without
// .config being accessable (write/read)

Check failure on line 312 in pkg/functions/client_int_test.go

View workflow job for this annotation

GitHub Actions / style / Golang / Lint

[github.com/client9/misspell] reported by reviewdog 🐶 "accessable" is a misspelling of "accessible" Raw Output: pkg/functions/client_int_test.go:312:17: "accessable" is a misspelling of "accessible"
// TODO: change this test to for-loop of Runs with different dir permissions?
func TestDeployWithoutWritableDotConfig(t *testing.T) {
// defer Within(t, "tempdata/example.com/baddotconfig")
root, cleanup := Mktemp(t)
defer cleanup()

t.Setenv("HOME", root)
verbose := true

// write new .config with no perms
err := os.Mkdir(path.Join(root, ".config"), 0000)
if err != nil {
t.Error(err)
}

f := fn.Function{Runtime: "go", Name: "test-deploy-no-perms-config", Root: root}

// client with pack builder
client := newClient(verbose)

// expect to fail on build for HOME not being defined with pack builder
_, _, err = client.New(context.Background(), f)
// this error should be 'permission denied' for trying to write to open .config
if err == nil {
t.Fatalf("expected an error but got nil")
}
// dont call del() because function wasnt deployed
}

// TestRemove deletes
func TestRemove(t *testing.T) {
defer Within(t, "testdata/example.com/remove")()
Expand Down

0 comments on commit f030066

Please sign in to comment.