-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
same as #11710 but for e2 Co-authored-by: JkLondon <[email protected]>
- Loading branch information
1 parent
afbb36b
commit 3e17cb9
Showing
5 changed files
with
225 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package snapcfg | ||
|
||
import ( | ||
"github.com/ledgerwatch/erigon-lib/downloader/snaptype" | ||
"testing" | ||
) | ||
|
||
func TestNameToParts(t *testing.T) { | ||
type args struct { | ||
name string | ||
v snaptype.Version | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
wantBlock uint64 | ||
wantErr bool | ||
}{ | ||
{ | ||
"happy pass", | ||
args{ | ||
name: "v1-asd-12-d", | ||
v: 0, | ||
}, | ||
12, | ||
false, | ||
}, | ||
{ | ||
"happy pass with version", | ||
args{ | ||
name: "v2-asd-12-d", | ||
v: 2, | ||
}, | ||
12, | ||
false, | ||
}, | ||
{ | ||
"happy pass && block in the end", | ||
args{ | ||
name: "v1-asd-12", | ||
v: 0, | ||
}, | ||
12, | ||
false, | ||
}, | ||
{ | ||
"version mismatch", | ||
args{ | ||
name: "v1-asd-12", | ||
v: 2, | ||
}, | ||
0, | ||
true, | ||
}, | ||
{ | ||
"block parse error", | ||
args{ | ||
name: "v1-asd-dd12", | ||
v: 0, | ||
}, | ||
0, | ||
true, | ||
}, | ||
{ | ||
"bad name", | ||
args{ | ||
name: "v1-dd12", | ||
v: 0, | ||
}, | ||
0, | ||
true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
gotBlock, err := ExtractBlockFromName(tt.args.name, tt.args.v) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("ExtractBlockFromName() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if gotBlock != tt.wantBlock { | ||
t.Errorf("ExtractBlockFromName() gotBlock = %v, want %v", gotBlock, tt.wantBlock) | ||
} | ||
}) | ||
} | ||
} |
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