-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into features/dependencies-alias
- Loading branch information
Showing
7 changed files
with
129 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,4 +82,5 @@ public String toString() { | |
return prettyJson; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.askimed.nf.test.util; | ||
|
||
import com.askimed.nf.test.lang.extensions.SnapshotFile; | ||
import groovy.json.JsonGenerator; | ||
import groovy.json.JsonOutput; | ||
|
||
import java.security.MessageDigest; | ||
import java.security.NoSuchAlgorithmException; | ||
|
||
public class ObjectUtil { | ||
|
||
public static String getMd5(Object object) { | ||
JsonGenerator jsonGenerator = SnapshotFile.createJsonGenerator(); | ||
String json = jsonGenerator.toJson(object); | ||
try { | ||
return calculateMD5(JsonOutput.prettyPrint(json)); | ||
} catch (NoSuchAlgorithmException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
|
||
public static String calculateMD5(String input) throws NoSuchAlgorithmException { | ||
// Get an instance of the MD5 message digest algorithm | ||
MessageDigest md = MessageDigest.getInstance("MD5"); | ||
|
||
// Update the digest with the input string's bytes | ||
md.update(input.getBytes()); | ||
|
||
// Get the hash value as an array of bytes | ||
byte[] digest = md.digest(); | ||
|
||
// Convert the byte array to a hexadecimal string | ||
StringBuilder result = new StringBuilder(); | ||
for (byte b : digest) { | ||
result.append(String.format("%02x", b)); | ||
} | ||
|
||
return result.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
nextflow_process { | ||
|
||
name "Test process xy" | ||
|
||
script "./process.nf" | ||
process "TEST_PROCESS" | ||
|
||
test("Should succeed because two unique snapshots") { | ||
|
||
when { | ||
process { | ||
""" | ||
input[0] = "Lukas" | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
|
||
def content = [ | ||
object1: "lukas", | ||
object2: 27, | ||
object3: [ | ||
a: "lll", | ||
b: [1,2,3,4,5,6] | ||
] | ||
] | ||
|
||
assert process.success | ||
assert snapshot(content).match() | ||
assert snapshot(content).md5().match("lukas") | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"Should succeed because two unique snapshots": { | ||
"content": [ | ||
{ | ||
"object1": "lukas", | ||
"object2": 27, | ||
"object3": { | ||
"a": "lll", | ||
"b": [ | ||
1, | ||
2, | ||
3, | ||
4, | ||
5, | ||
6 | ||
] | ||
} | ||
} | ||
], | ||
"timestamp": "2024-01-28T11:41:29.018819" | ||
}, | ||
"lukas": { | ||
"content": "a54d97026c5ed6e6a57ccd3a3f5a3cbc", | ||
"timestamp": "2024-01-28T11:41:29.025981" | ||
} | ||
} |