MCPcopy Index your code
hub / github.com/larksuite/cli / TestAssertSecurePath_FileDoesNotExist

Function TestAssertSecurePath_FileDoesNotExist

internal/binding/audit_test.go:30–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func TestAssertSecurePath_FileDoesNotExist(t *testing.T) {
31 nonexistent := filepath.Join(t.TempDir(), "nonexistent.txt")
32 _, err := AssertSecurePath(AuditParams{
33 TargetPath: nonexistent,
34 Label: "test",
35 AllowInsecurePath: true,
36 })
37 if err == nil {
38 t.Fatal("expected error for non-existent file, got nil")
39 }
40 wantPrefix := fmt.Sprintf("test: cannot stat %q: ", nonexistent)
41 if !strings.HasPrefix(err.Error(), wantPrefix) {
42 t.Errorf("error = %q, want prefix %q", err.Error(), wantPrefix)
43 }
44}
45
46func TestAssertSecurePath_ValidAbsolutePath(t *testing.T) {
47 dir := t.TempDir()

Callers

nothing calls this directly

Calls 2

AssertSecurePathFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected