-
Notifications
You must be signed in to change notification settings - Fork 597
/
Copy pathfast_weights_test.go
47 lines (42 loc) · 1 KB
/
fast_weights_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package weights
import (
"encoding/json"
"os"
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestFindFastWeights(t *testing.T) {
folder := t.TempDir()
tmpDir := t.TempDir()
weights, err := FindFastWeights(folder, tmpDir)
require.NoError(t, err)
require.Empty(t, weights)
}
func TestFindFastWeightsWithRemovedWeight(t *testing.T) {
folder := t.TempDir()
tmpDir := t.TempDir()
weightFile := filepath.Join(tmpDir, WEIGHT_FILE)
weights := []Weight{
{
Path: "nonexistent_weight.h5",
Digest: "1",
Timestamp: time.Now(),
Size: 10,
},
}
jsonData, err := json.MarshalIndent(weights, "", " ")
require.NoError(t, err)
err = os.WriteFile(weightFile, jsonData, 0o644)
require.NoError(t, err)
weights, err = FindFastWeights(folder, tmpDir)
require.NoError(t, err)
require.Empty(t, weights)
}
func TestReadFastWeightsNoFile(t *testing.T) {
dir := t.TempDir()
weights, err := ReadFastWeights(dir)
require.NoError(t, err)
require.Empty(t, weights)
}