Issues with diffs
markussiebert opened this issue · 2 comments
Hi,
coming from typescript and jest I really like your work and can save a lot of lines of code in my unit tests! But I have an edge case where the snapshot/match logic does not work.
This is the initial snapshot:
[Test_GetS3FileContent - 1]
{
"key1": "ENC[AES256_GCM,data:ArSjC0Vd,iv:NFrIj1ekM2dU8JCU6NpmnHFmwcFaEQagCw/fxKV2b6A=,tag:GrGgeNmtqFuyiTjKJ/78kw==,type:str]",
"key2": "ENC[AES256_GCM,data:NeoandY=,iv:2oCcBk0R/XxvH/O+aaCIa7V9pFsy7dhCKZ70ebjc5Ds=,tag:GVZXUFFwbpMVY/KCLNENAQ==,type:float]",
"key3": "ENC[AES256_GCM,data:y4tBaNg=,iv:mHuYrtf0Ke/oHBcunpgdPpzaYkBx7UjMcOQgpmVc8/Q=,tag:cuEg2UE17Po6opfpH8ikog==,type:bool]",
"sops": {
"kms": null,
"gcp_kms": null,
"azure_kv": null,
"hc_vault": null,
"age": [
{
"recipient": "age1djllw2pzuprrqc0en5m8vc8k5ge3tm0f6g7cj0c0glfzp44vdc4ql8ngvu",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBOWlAxekVNNXdjenV5cmdR\nZDlQU3N5WC9oeENUbUpYcWxkeU9kVS9TeUR3Cm5zbGhIL0J6WG9TWi9KR3ZUTVph\nblpiUDZtQklnWlRrSGZzTXlZN2Z6WjgKLS0tIDI3ZHNHR0NmWTMzdTg0dEtXcU93\nbEdNWndKdWROWGdLdHAwTGFtRGlsaDQKV7HJG629rPWDBY046Hxj4utxUkex3SwU\nVUQRX00p6r9ffc+iC5DGUm/KOketAHunO4Kn0uOS4WHg+Jg2Cwu72Q==\n-----END AGE ENCRYPTED FILE-----\n"
}
],
"lastmodified": "2022-03-29T21:02:32Z",
"mac": "ENC[AES256_GCM,data:2vmzwW74OSJq18GEcScpMH76AWrhJdENlKw2vRzGrQfPixTNcrwJ0neTH+BvGKfR9OlLR2EZTheRphQ0Ikb4SdhfInoDjHo+0jXN7RQ4neTlko4j/YRVek61oePgAKAqcmvL2IhzRGO2VR8nDPuJuvRCmP5wOMOBkerydRKHeDc=,iv:NHWPNWDmuhekJUIJpC1cDJ51lLKTsXLE6dC4tpw/qSI=,tag:yV5ngRdIYZfUgj6ntsY5CQ==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted",
"version": "3.7.2"
}
}
The second run already fails:
2022/04/03 12:18:34 Downloaded 1403 bytes
main_test.go:31:
Snapshot
Received
{
"key1": "ENC[AES256_GCM,data:ArSjC0Vd,iv:NFrIj1ekM2dU8JCU6NpmnHFmwcFaEQagCw/fxKV2b6A=,tag:GrGgeNmtqFuyiTjKJ/78kw==,type:str]",
"key2": "ENC[AES256_GCM,data:NeoandY=,iv:2oCcBk0R/XxvH/O+aaCIa7V9pFsy7dhCKZ70ebjc5Ds=,tag:GVZXUFFwbpMVY/KCLNENAQ==,type:float]",
"key3": "ENC[AES256_GCM,data:y4tBaNg=,iv:mHuYrtf0Ke/oHBcunpgdPpzaYkBx7UjMcOQgpmVc8/Q=,tag:cuEg2UE17Po6opfpH8ikog==,type:bool]",
"sops": {
"kms": null,
"gcp_kms": null,
"azure_kv": null,
"hc_vault": null,
"age": [
{
"recipient": "age1djllw2pzuprrqc0en5m8vc8k5ge3tm0f6g7cj0c0glfzp44vdc4ql8ngvu",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBOWlAxekVNNXdjenV5cmdR\nZDlQU3N5WC9oeENUbUpYcWxkeU9kVS9TeUR3Cm5zbGhIL0J6WG9TWi9KR3ZUTVph\nblpiUDZtQklnWlRrSGZzTXlZN2Z6WjgKLS0tIDI3ZHNHR0NmWTMzdTg0dEtXcU93\nbEdNWndKdWROWGdLdHAwTGFtRGlsaDQKV7HJG629rPWDBY046Hxj4utxUkex3SwU\nVUQRX00p6r9ffc+iC5DGUm/KOketAHunO4Kn0uOS4WHg+Jg2Cwu72Q==\n-----END AGE ENCRYPTED FILE-----\n"
}
],
"lastmodified": "2022-03-29T21:02:32Z",
"mac": "ENC[AES256_GCM,data:2vmzwW74OSJq18GEcScpMH76AWrhJdENlKw2vRzGrQfPixTNcrwJ0neTH+BvGKfR9OlLR2EZTheRphQ0Ikb4SdhfInoDjHo+0jXN7RQ4neTlko4j/YRVek61oePgAKAqcmvL2IhzRGO2VR8nDPuJuvRCmP5wOMOBkerydRKHeDc=,iv:NHWPNWDmuhekJUIJpC1cDJ51lLKTsXLE6dC4tpw/qSI=,tag:yV5ngRdIYZfUgj6ntsY5CQ==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted",
"version": "3.7.2"
}
}
An image can tell more than thousand words:
And after updating the snapshot 2 more times, the snapshot looks like:
[Test_GetS3FileContent - 1]
{
"key1": "ENC[AES256_GCM,data:ArSjC0Vd,iv:NFrIj1ekM2dU8JCU6NpmnHFmwcFaEQagCw/fxKV2b6A=,tag:GrGgeNmtqFuyiTjKJ/78kw==,type:str]",
"key2": "ENC[AES256_GCM,data:NeoandY=,iv:2oCcBk0R/XxvH/O+aaCIa7V9pFsy7dhCKZ70ebjc5Ds=,tag:GVZXUFFwbpMVY/KCLNENAQ==,type:float]",
"key3": "ENC[AES256_GCM,data:y4tBaNg=,iv:mHuYrtf0Ke/oHBcunpgdPpzaYkBx7UjMcOQgpmVc8/Q=,tag:cuEg2UE17Po6opfpH8ikog==,type:bool]",
"sops": {
"kms": null,
"gcp_kms": null,
"azure_kv": null,
"hc_vault": null,
"age": [
{
"recipient": "age1djllw2pzuprrqc0en5m8vc8k5ge3tm0f6g7cj0c0glfzp44vdc4ql8ngvu",
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBOWlAxekVNNXdjenV5cmdR\nZDlQU3N5WC9oeENUbUpYcWxkeU9kVS9TeUR3Cm5zbGhIL0J6WG9TWi9KR3ZUTVph\nblpiUDZtQklnWlRrSGZzTXlZN2Z6WjgKLS0tIDI3ZHNHR0NmWTMzdTg0dEtXcU93\nbEdNWndKdWROWGdLdHAwTGFtRGlsaDQKV7HJG629rPWDBY046Hxj4utxUkex3SwU\nVUQRX00p6r9ffc+iC5DGUm/KOketAHunO4Kn0uOS4WHg+Jg2Cwu72Q==\n-----END AGE ENCRYPTED FILE-----\n"
}
],
"lastmodified": "2022-03-29T21:02:32Z",
"mac": "ENC[AES256_GCM,data:2vmzwW74OSJq18GEcScpMH76AWrhJdENlKw2vRzGrQfPixTNcrwJ0neTH+BvGKfR9OlLR2EZTheRphQ0Ikb4SdhfInoDjHo+0jXN7RQ4neTlko4j/YRVek61oePgAKAqcmvL2IhzRGO2VR8nDPuJuvRCmP5wOMOBkerydRKHeDc=,iv:NHWPNWDmuhekJUIJpC1cDJ51lLKTsXLE6dC4tpw/qSI=,tag:yV5ngRdIYZfUgj6ntsY5CQ==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted",
"version": "3.7.2"
}
}
-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBOWlAxekVNNXdjenV5cmdR\nZDlQU3N5WC9oeENUbUpYcWxkeU9kVS9TeUR3Cm5zbGhIL0J6WG9TWi9KR3ZUTVph\nblpiUDZtQklnWlRrSGZzTXlZN2Z6WjgKLS0tIDI3ZHNHR0NmWTMzdTg0dEtXcU93\nbEdNWndKdWROWGdLdHAwTGFtRGlsaDQKV7HJG629rPWDBY046Hxj4utxUkex3SwU\nVUQRX00p6r9ffc+iC5DGUm/KOketAHunO4Kn0uOS4WHg+Jg2Cwu72Q==\n-----END AGE ENCRYPTED FILE-----\n"
}
],
"lastmodified": "2022-03-29T21:02:32Z",
"mac": "ENC[AES256_GCM,data:2vmzwW74OSJq18GEcScpMH76AWrhJdENlKw2vRzGrQfPixTNcrwJ0neTH+BvGKfR9OlLR2EZTheRphQ0Ikb4SdhfInoDjHo+0jXN7RQ4neTlko4j/YRVek61oePgAKAqcmvL2IhzRGO2VR8nDPuJuvRCmP5wOMOBkerydRKHeDc=,iv:NHWPNWDmuhekJUIJpC1cDJ51lLKTsXLE6dC4tpw/qSI=,tag:yV5ngRdIYZfUgj6ntsY5CQ==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted",
"version": "3.7.2"
}
}
-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBOWlAxekVNNXdjenV5cmdR\nZDlQU3N5WC9oeENUbUpYcWxkeU9kVS9TeUR3Cm5zbGhIL0J6WG9TWi9KR3ZUTVph\nblpiUDZtQklnWlRrSGZzTXlZN2Z6WjgKLS0tIDI3ZHNHR0NmWTMzdTg0dEtXcU93\nbEdNWndKdWROWGdLdHAwTGFtRGlsaDQKV7HJG629rPWDBY046Hxj4utxUkex3SwU\nVUQRX00p6r9ffc+iC5DGUm/KOketAHunO4Kn0uOS4WHg+Jg2Cwu72Q==\n-----END AGE ENCRYPTED FILE-----\n"
}
],
"lastmodified": "2022-03-29T21:02:32Z",
"mac": "ENC[AES256_GCM,data:2vmzwW74OSJq18GEcScpMH76AWrhJdENlKw2vRzGrQfPixTNcrwJ0neTH+BvGKfR9OlLR2EZTheRphQ0Ikb4SdhfInoDjHo+0jXN7RQ4neTlko4j/YRVek61oePgAKAqcmvL2IhzRGO2VR8nDPuJuvRCmP5wOMOBkerydRKHeDc=,iv:NHWPNWDmuhekJUIJpC1cDJ51lLKTsXLE6dC4tpw/qSI=,tag:yV5ngRdIYZfUgj6ntsY5CQ==,type:str]",
"pgp": null,
"unencrypted_suffix": "_unencrypted",
"version": "3.7.2"
}
}
So I think something within this line is breaking the snapshot/diff logic:
"enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBOWlAxekVNNXdjenV5cmdR\nZDlQU3N5WC9oeENUbUpYcWxkeU9kVS9TeUR3Cm5zbGhIL0J6WG9TWi9KR3ZUTVph\nblpiUDZtQklnWlRrSGZzTXlZN2Z6WjgKLS0tIDI3ZHNHR0NmWTMzdTg0dEtXcU93\nbEdNWndKdWROWGdLdHAwTGFtRGlsaDQKV7HJG629rPWDBY046Hxj4utxUkex3SwU\nVUQRX00p6r9ffc+iC5DGUm/KOketAHunO4Kn0uOS4WHg+Jg2Cwu72Q==\n-----END AGE ENCRYPTED FILE-----\n"
Maybe you have an idea what's wrong?
Further testing showed, that replacing "-----" with "" is a possible workaround
Hey 👋, thanks for raising this issue and for the really helpful and thorough explanation with examples of what's the problem.
Maybe you have an idea what's wrong?
Further testing showed, that replacing "-----" with "" is a possible workaround
The problem is the snapshots are saved in the file as
[ test name - id] <- marking start of snapshot
<data>
--- <- marking end of snapshot
So inside your test you had ---
breaking the logic 😓 . Going to have a pr asap fixing this issue
Thank you for your fast answer. Don't feel presured ;-) My workaround with replacing the ----
works well. The other problem is not so easy to fix for me.