@@ -162,6 +162,7 @@ func TestHash(t *testing.T) {
162
162
163
163
roots , err := app .Run (context .Background ())
164
164
require .NoError (t , err )
165
+ assert .False (t , ScreensFromRoots (roots ).Empty ())
165
166
166
167
// ensure we can calculate a hash
167
168
hash , err := ScreensFromRoots (roots ).Hash ()
@@ -185,11 +186,33 @@ func TestHash(t *testing.T) {
185
186
186
187
// ensure we can calculate a hash on the new app
187
188
hash2 , err := ScreensFromRoots (roots2 ).Hash ()
189
+ require .NoError (t , err )
188
190
189
191
// ensure hashes are different
190
192
require .NotEqual (t , hash , hash2 )
191
193
}
192
194
195
+ func TestHashEmptyApp (t * testing.T ) {
196
+ app , err := runtime .NewApplet ("test.star" , []byte (`def main(): return []` ))
197
+ require .NoError (t , err )
198
+
199
+ roots , err := app .Run (context .Background ())
200
+ require .NoError (t , err )
201
+ assert .True (t , ScreensFromRoots (roots ).Empty ())
202
+
203
+ // ensure we can calculate a hash
204
+ hash , err := ScreensFromRoots (roots ).Hash ()
205
+ require .NoError (t , err )
206
+ require .True (t , len (hash ) > 0 )
207
+
208
+ // ensure the hash doesn't change
209
+ for i := 0 ; i < 20 ; i ++ {
210
+ h , err := ScreensFromRoots (roots ).Hash ()
211
+ assert .NoError (t , err )
212
+ assert .Equal (t , hash , h )
213
+ }
214
+ }
215
+
193
216
func TestHashDelayAndMaxAge (t * testing.T ) {
194
217
r := []render.Root {{Child : & render.Text {Content : "derp" }}}
195
218
0 commit comments