Skip to content

Commit

Permalink
feat: add unit test SecureMkdirAll func
Browse files Browse the repository at this point in the history
Signed-off-by: thisishwan2 <[email protected]>
  • Loading branch information
thisishwan2 committed Aug 2, 2024
1 parent 7388c63 commit 54dcc1d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
24 changes: 24 additions & 0 deletions commitserver/commit/default_mkdir_provider_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//go:build !linux
// +build !linux

package commit

import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"os"
"path"
"testing"
)

func TestSecureMkdirAllDefault(t *testing.T) {
root := t.TempDir()

// hydratePath
hydratePath := "test/dir"
fullHydratePath, err := SecureMkdirAll(root, hydratePath, os.ModePerm)
require.NoError(t, err)

expectedPath := path.Join(root, hydratePath)
assert.Equal(t, expectedPath, fullHydratePath)
}
22 changes: 22 additions & 0 deletions commitserver/commit/linux_mkdir_provider_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//go:build linux
// +build linux

package commit

import (
"github.com/stretchr/testify/require"
"os"
"testing"
)

func TestSecureMkdirAllLinux(t *testing.T) {
root := t.TempDir()

// hydratePath
hydratePath := "test/dir"
fullHydratePath, err := SecureMkdirAll(root, hydratePath, os.ModePerm)
require.NoError(t, err)

expectedPath := path.Join(root, hydratePath)
require.Equal(t, expectedPath, fullHydratePath)
}

0 comments on commit 54dcc1d

Please sign in to comment.