diff options
Diffstat (limited to 'HutchTests')
| -rw-r--r-- | HutchTests/RepositoryDeployKeyTests.swift | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/HutchTests/RepositoryDeployKeyTests.swift b/HutchTests/RepositoryDeployKeyTests.swift new file mode 100644 index 0000000..c6ff667 --- /dev/null +++ b/HutchTests/RepositoryDeployKeyTests.swift @@ -0,0 +1,27 @@ +import Foundation +import Testing +@testable import Hutch + +struct RepositoryDeployKeyTests { + @Test + func decodesDeployKey() throws { + let json = """ + { "rid": "k1", "keyType": "ssh-ed25519", "fingerprintSHA256": "SHA256:abc", "comment": "laptop", "access": "RW" } + """ + let key = try JSONDecoder().decode(RepositoryDeployKey.self, from: Data(json.utf8)) + #expect(key.rid == "k1") + #expect(key.id == "k1") + #expect(key.access == .rw) + #expect(key.comment == "laptop") + } + + @Test + func decodesDeployKeyWithNullComment() throws { + let json = """ + { "rid": "k2", "keyType": "ssh-rsa", "fingerprintSHA256": "SHA256:def", "comment": null, "access": "RO" } + """ + let key = try JSONDecoder().decode(RepositoryDeployKey.self, from: Data(json.utf8)) + #expect(key.comment == nil) + #expect(key.access == .ro) + } +} |
