-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage_test.go
More file actions
92 lines (79 loc) · 2.75 KB
/
image_test.go
File metadata and controls
92 lines (79 loc) · 2.75 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package consolizer_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/supercom32/consolizer"
"github.com/supercom32/consolizer/types"
)
func setupTest() {
imageAliases := []string{}
for alias := range consolizer.Image.Entries {
imageAliases = append(imageAliases, alias)
}
for _, alias := range imageAliases {
consolizer.DeleteImage(alias)
}
}
func TestAddAndGetImage(t *testing.T) {
setupTest()
imageAlias := "testImage"
imageEntry := types.ImageEntryType{}
consolizer.AddImage(imageAlias, imageEntry)
retrievedImage := consolizer.GetImage(imageAlias)
assert.NotNil(t, retrievedImage, "Retrieved image should not be nil")
assert.True(t, consolizer.IsImageExists(imageAlias), "Image should exist after being added")
}
func TestGetNonExistentImage(t *testing.T) {
setupTest()
imageAlias := "nonExistentImage"
assert.PanicsWithValue(t,
"The requested Image with alias 'nonExistentImage' could not be returned since it does not exist.",
func() {
consolizer.GetImage(imageAlias)
}, "Should panic when getting a non-existent image")
}
func TestDeleteImage(t *testing.T) {
setupTest()
imageAlias := "testImageToDelete"
imageEntry := types.ImageEntryType{}
consolizer.AddImage(imageAlias, imageEntry)
consolizer.DeleteImage(imageAlias)
assert.False(t, consolizer.IsImageExists(imageAlias), "Image should no longer exist after being deleted")
}
func TestIsImageExists(t *testing.T) {
setupTest()
imageAlias := "existingImage"
imageEntry := types.ImageEntryType{}
consolizer.AddImage(imageAlias, imageEntry)
assert.True(t, consolizer.IsImageExists(imageAlias), "Image should exist after being added")
assert.False(t, consolizer.IsImageExists("nonExistentImage"), "Non-existent image should return false")
}
func TestUnloadImage(t *testing.T) {
setupTest()
imageAlias := "imageToBeUnloaded"
imageEntry := types.ImageEntryType{}
consolizer.AddImage(imageAlias, imageEntry)
consolizer.UnloadImage(imageAlias)
assert.False(t, consolizer.IsImageExists(imageAlias), "Image should no longer exist after being unloaded")
}
func TestLoadImage(t *testing.T) {
t.Skip("Requires mocking of filesystem operations")
}
func TestLoadImagesInBulk(t *testing.T) {
t.Skip("Requires mocking of LoadImage behavior")
}
func TestLoadPreRenderedImage(t *testing.T) {
t.Skip("Requires mocking of filesystem operations")
}
func TestDeleteNonExistentImage(t *testing.T) {
setupTest()
nonExistentImageAlias := "nonExistentImage"
consolizer.DeleteImage(nonExistentImageAlias)
assert.False(t, consolizer.IsImageExists(nonExistentImageAlias))
}
func TestUnloadNonExistentImage(t *testing.T) {
setupTest()
nonExistentImageAlias := "nonExistentImage"
consolizer.UnloadImage(nonExistentImageAlias)
assert.False(t, consolizer.IsImageExists(nonExistentImageAlias))
}