mirror of
https://github.com/sbrow/envr.git
synced 2026-06-27 10:38:33 -04:00
refactor: Fixed a number of memory leaks.
This commit is contained in:
@@ -5,39 +5,44 @@ import "core:testing"
|
||||
|
||||
@(test)
|
||||
test_find_unbacked_finds_missing :: proc(t: ^testing.T) {
|
||||
local := []string{"/a/.env", "/b/.env", "/c/.env"}
|
||||
db := []EnvFile{{Path = "/a/.env"}, {Path = "/b/.env"}}
|
||||
local := []string{"/a/.env", "/b/.env", "/c/.env"}
|
||||
db := []EnvFile{{Path = "/a/.env"}, {Path = "/b/.env"}}
|
||||
|
||||
result := find_unbacked(local, db[:])
|
||||
testing.expect(t, len(result) == 1, fmt.aprintf("expected 1 unbacked, got %d", len(result)))
|
||||
if len(result) > 0 {
|
||||
testing.expect(t, result[0] == "/c/.env", fmt.aprintf("expected /c/.env, got %s", result[0]))
|
||||
}
|
||||
result := find_unbacked(local, db[:])
|
||||
testing.expect(t, len(result) == 1, fmt.aprintf("expected 1 unbacked, got %d", len(result)))
|
||||
if len(result) > 0 {
|
||||
testing.expect(
|
||||
t,
|
||||
result[0] == "/c/.env",
|
||||
fmt.aprintf("expected /c/.env, got %s", result[0]),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_find_unbacked_all_backed :: proc(t: ^testing.T) {
|
||||
local := []string{"/a/.env", "/b/.env"}
|
||||
db := []EnvFile{{Path = "/a/.env"}, {Path = "/b/.env"}}
|
||||
local := []string{"/a/.env", "/b/.env"}
|
||||
db := []EnvFile{{Path = "/a/.env"}, {Path = "/b/.env"}}
|
||||
|
||||
result := find_unbacked(local, db[:])
|
||||
testing.expect(t, len(result) == 0, fmt.aprintf("expected 0 unbacked, got %d", len(result)))
|
||||
result := find_unbacked(local, db[:])
|
||||
testing.expect(t, len(result) == 0, fmt.aprintf("expected 0 unbacked, got %d", len(result)))
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_find_unbacked_no_local :: proc(t: ^testing.T) {
|
||||
local: []string
|
||||
db := []EnvFile{{Path = "/a/.env"}}
|
||||
local: []string
|
||||
db := []EnvFile{{Path = "/a/.env"}}
|
||||
|
||||
result := find_unbacked(local, db[:])
|
||||
testing.expect(t, len(result) == 0, fmt.aprintf("expected 0 unbacked, got %d", len(result)))
|
||||
result := find_unbacked(local, db[:])
|
||||
testing.expect(t, len(result) == 0, fmt.aprintf("expected 0 unbacked, got %d", len(result)))
|
||||
}
|
||||
|
||||
@(test)
|
||||
test_find_unbacked_none_backed :: proc(t: ^testing.T) {
|
||||
local := []string{"/a/.env", "/b/.env"}
|
||||
db: []EnvFile
|
||||
local := []string{"/a/.env", "/b/.env"}
|
||||
db: []EnvFile
|
||||
|
||||
result := find_unbacked(local, db[:])
|
||||
testing.expect(t, len(result) == 2, fmt.aprintf("expected 2 unbacked, got %d", len(result)))
|
||||
result := find_unbacked(local, db[:])
|
||||
testing.expect(t, len(result) == 2, fmt.aprintf("expected 2 unbacked, got %d", len(result)))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user