fix test
This commit is contained in:
		
							parent
							
								
									d1ccb1c762
								
							
						
					
					
						commit
						a2e8249003
					
				| @ -1,20 +1,15 @@ | |||||||
| import kotlinx.serialization.ExperimentalSerializationApi | import kotlinx.serialization.ExperimentalSerializationApi | ||||||
| import kotlinx.serialization.json.Json | import kotlinx.serialization.json.Json | ||||||
| import kotlinx.serialization.json.decodeFromStream |  | ||||||
| import java.io.File |  | ||||||
| import kotlin.test.Test |  | ||||||
| import kotlin.test.assertEquals |  | ||||||
| 
 |  | ||||||
| import moe.rosa.planterette.hakurei.* | import moe.rosa.planterette.hakurei.* | ||||||
| import org.junit.jupiter.api.assertDoesNotThrow | import org.junit.jupiter.api.assertDoesNotThrow | ||||||
| import org.junit.jupiter.api.assertThrows | import kotlin.test.Test | ||||||
| import kotlin.test.assertFails | import kotlin.test.assertEquals | ||||||
| import kotlin.test.assertFailsWith | import kotlin.test.assertFailsWith | ||||||
| import kotlin.test.assertIs | import kotlin.test.assertIs | ||||||
| 
 | 
 | ||||||
| class HakureiTest { | class HakureiTest { | ||||||
|     companion object { |     companion object { | ||||||
|         val CHROMIUM_TEMPLATE = HakureiConfig( |         val TEMPLATE_DATA = HakureiConfig( | ||||||
|             id = "org.chromium.Chromium", |             id = "org.chromium.Chromium", | ||||||
|             path = AbsolutePath("/run/current-system/sw/bin/chromium"), |             path = AbsolutePath("/run/current-system/sw/bin/chromium"), | ||||||
|             args = listOf( |             args = listOf( | ||||||
| @ -159,22 +154,31 @@ class HakureiTest { | |||||||
|                 ) |                 ) | ||||||
|             ) |             ) | ||||||
|         ) |         ) | ||||||
|         val format = Json { prettyPrint = true } |         val TEMPLATE_JSON = ProcessBuilder("hakurei", "template") | ||||||
|  |             .start() | ||||||
|  |             .inputStream | ||||||
|  |             .readAllBytes() | ||||||
|  |             .toString(Charsets.UTF_8) | ||||||
|  |         val format = Json { | ||||||
|  |             prettyPrint = true | ||||||
|  |             ignoreUnknownKeys = true | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @OptIn(ExperimentalSerializationApi::class) |     @OptIn(ExperimentalSerializationApi::class) | ||||||
|     @Test |     @Test | ||||||
|     fun deserializeTest() { |     fun deserializeTest() { | ||||||
|         println(System.getProperty("user.dir")) | 
 | ||||||
|         val want = format.decodeFromStream<HakureiConfig>(File("/home/mae/Documents/Projects/Rosa/planterette/src/test/resources/hakurei-chromium.json").inputStream()) |         println(TEMPLATE_JSON) | ||||||
|         assertEquals(CHROMIUM_TEMPLATE, want) |         val want = format.decodeFromString<HakureiConfig>(TEMPLATE_JSON) | ||||||
|  |         assertEquals(TEMPLATE_DATA, want) | ||||||
|     } |     } | ||||||
|     @OptIn(ExperimentalSerializationApi::class) |     @OptIn(ExperimentalSerializationApi::class) | ||||||
|     @Test |     @Test | ||||||
|     fun serializeTest() { |     fun serializeTest() { | ||||||
|         val encoded = format.encodeToString(CHROMIUM_TEMPLATE) |         val encoded = format.encodeToString(TEMPLATE_DATA) | ||||||
|         val decoded = format.decodeFromString<HakureiConfig>(encoded) |         val decoded = format.decodeFromString<HakureiConfig>(encoded) | ||||||
|         assertEquals(CHROMIUM_TEMPLATE, decoded) |         assertEquals(TEMPLATE_DATA, decoded) | ||||||
|     } |     } | ||||||
|     @Test |     @Test | ||||||
|     fun absolutePathTest() { |     fun absolutePathTest() { | ||||||
| @ -188,6 +192,6 @@ class HakureiTest { | |||||||
|     } |     } | ||||||
|     @Test |     @Test | ||||||
|     fun extraPermsTest() { |     fun extraPermsTest() { | ||||||
|         assertIs<String>(CHROMIUM_TEMPLATE.extraPerms.toString()) |         assertIs<String>(TEMPLATE_DATA.extraPerms.toString()) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -1,146 +0,0 @@ | |||||||
| { |  | ||||||
|   "id": "org.chromium.Chromium", |  | ||||||
|   "path": "/run/current-system/sw/bin/chromium", |  | ||||||
|   "args": [ |  | ||||||
|     "chromium", |  | ||||||
|     "--ignore-gpu-blocklist", |  | ||||||
|     "--disable-smooth-scrolling", |  | ||||||
|     "--enable-features=UseOzonePlatform", |  | ||||||
|     "--ozone-platform=wayland" |  | ||||||
|   ], |  | ||||||
|   "enablements": { |  | ||||||
|     "wayland": true, |  | ||||||
|     "dbus": true, |  | ||||||
|     "pulse": true |  | ||||||
|   }, |  | ||||||
|   "session_bus": { |  | ||||||
|     "talk": [ |  | ||||||
|       "org.freedesktop.Notifications", |  | ||||||
|       "org.freedesktop.FileManager1", |  | ||||||
|       "org.freedesktop.ScreenSaver", |  | ||||||
|       "org.freedesktop.secrets", |  | ||||||
|       "org.kde.kwalletd5", |  | ||||||
|       "org.kde.kwalletd6", |  | ||||||
|       "org.gnome.SessionManager" |  | ||||||
|     ], |  | ||||||
|     "own": [ |  | ||||||
|       "org.chromium.Chromium.*", |  | ||||||
|       "org.mpris.MediaPlayer2.org.chromium.Chromium.*", |  | ||||||
|       "org.mpris.MediaPlayer2.chromium.*" |  | ||||||
|     ], |  | ||||||
|     "call": { |  | ||||||
|       "org.freedesktop.portal.*": "*" |  | ||||||
|     }, |  | ||||||
|     "broadcast": { |  | ||||||
|       "org.freedesktop.portal.*": "@/org/freedesktop/portal/*" |  | ||||||
|     }, |  | ||||||
|     "filter": true |  | ||||||
|   }, |  | ||||||
|   "system_bus": { |  | ||||||
|     "talk": [ |  | ||||||
|       "org.bluez", |  | ||||||
|       "org.freedesktop.Avahi", |  | ||||||
|       "org.freedesktop.UPower" |  | ||||||
|     ], |  | ||||||
|     "filter": true |  | ||||||
|   }, |  | ||||||
|   "username": "chronos", |  | ||||||
|   "shell": "/run/current-system/sw/bin/zsh", |  | ||||||
|   "home": "/data/data/org.chromium.Chromium", |  | ||||||
|   "extra_perms": [ |  | ||||||
|     { |  | ||||||
|       "ensure": true, |  | ||||||
|       "path": "/var/lib/hakurei/u0", |  | ||||||
|       "x": true |  | ||||||
|     }, |  | ||||||
|     { |  | ||||||
|       "path": "/var/lib/hakurei/u0/org.chromium.Chromium", |  | ||||||
|       "r": true, |  | ||||||
|       "w": true, |  | ||||||
|       "x": true |  | ||||||
|     } |  | ||||||
|   ], |  | ||||||
|   "identity": 9, |  | ||||||
|   "groups": [ |  | ||||||
|     "video", |  | ||||||
|     "dialout", |  | ||||||
|     "plugdev" |  | ||||||
|   ], |  | ||||||
|   "container": { |  | ||||||
|     "hostname": "localhost", |  | ||||||
|     "wait_delay": -1, |  | ||||||
|     "seccomp_compat": true, |  | ||||||
|     "devel": true, |  | ||||||
|     "userns": true, |  | ||||||
|     "host_net": true, |  | ||||||
|     "host_abstract": true, |  | ||||||
|     "tty": true, |  | ||||||
|     "multiarch": true, |  | ||||||
|     "env": { |  | ||||||
|       "GOOGLE_API_KEY": "AIzaSyBHDrl33hwRp4rMQY0ziRbj8K9LPA6vUCY", |  | ||||||
|       "GOOGLE_DEFAULT_CLIENT_ID": "77185425430.apps.googleusercontent.com", |  | ||||||
|       "GOOGLE_DEFAULT_CLIENT_SECRET": "OTJgUOQcT7lO7GsGZq2G4IlT" |  | ||||||
|     }, |  | ||||||
|     "map_real_uid": true, |  | ||||||
|     "device": true, |  | ||||||
|     "filesystem": [ |  | ||||||
|       { |  | ||||||
|         "type": "bind", |  | ||||||
|         "dst": "/", |  | ||||||
|         "src": "/var/lib/hakurei/base/org.debian", |  | ||||||
|         "write": true, |  | ||||||
|         "special": true |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "type": "bind", |  | ||||||
|         "dst": "/etc/", |  | ||||||
|         "src": "/etc/", |  | ||||||
|         "special": true |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "type": "ephemeral", |  | ||||||
|         "dst": "/tmp/", |  | ||||||
|         "write": true, |  | ||||||
|         "perm": 493 |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "type": "overlay", |  | ||||||
|         "dst": "/nix/store", |  | ||||||
|         "lower": [ |  | ||||||
|           "/mnt-root/nix/.ro-store" |  | ||||||
|         ], |  | ||||||
|         "upper": "/mnt-root/nix/.rw-store/upper", |  | ||||||
|         "work": "/mnt-root/nix/.rw-store/work" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "type": "bind", |  | ||||||
|         "src": "/nix/store" |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "type": "link", |  | ||||||
|         "dst": "/run/current-system", |  | ||||||
|         "linkname": "/run/current-system", |  | ||||||
|         "dereference": true |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "type": "link", |  | ||||||
|         "dst": "/run/opengl-driver", |  | ||||||
|         "linkname": "/run/opengl-driver", |  | ||||||
|         "dereference": true |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "type": "bind", |  | ||||||
|         "dst": "/data/data/org.chromium.Chromium", |  | ||||||
|         "src": "/var/lib/hakurei/u0/org.chromium.Chromium", |  | ||||||
|         "write": true, |  | ||||||
|         "ensure": true |  | ||||||
|       }, |  | ||||||
|       { |  | ||||||
|         "type": "bind", |  | ||||||
|         "src": "/dev/dri", |  | ||||||
|         "dev": true, |  | ||||||
|         "optional": true |  | ||||||
|       } |  | ||||||
|     ] |  | ||||||
|   } |  | ||||||
| } |  | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user