pkg/utils: Test PathExists

https://github.com/containers/toolbox/pull/1629
This commit is contained in:
Debarshi Ray 2025-04-28 13:29:28 +02:00
parent c4df57944e
commit e9e77fb069
1 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright © 2021 2024 Red Hat Inc.
* Copyright © 2021 2025 Red Hat Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package utils
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
@ -361,3 +362,14 @@ func TestParseRelease(t *testing.T) {
})
}
}
func TestPathExists(t *testing.T) {
path, err := os.Executable()
assert.NoError(t, err)
exists := PathExists(path)
assert.True(t, exists)
path = "/does/not/exist"
exists = PathExists(path)
assert.False(t, exists)
}