mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
tests for protocol.go
Signed-off-by: Alfredo Deza <adeza@anchore.com>
This commit is contained in:
parent
c35108b00d
commit
3eedb86a1f
43
imgbom/protocol_test.go
Normal file
43
imgbom/protocol_test.go
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package imgbom
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestNewProtocol(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
desc string
|
||||||
|
input string
|
||||||
|
expType ProtocolType
|
||||||
|
expValue string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
desc: "directory protocol",
|
||||||
|
input: "dir:///opt/",
|
||||||
|
expType: DirProtocol,
|
||||||
|
expValue: "/opt/",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "unknown protocol",
|
||||||
|
input: "s4:///opt/",
|
||||||
|
expType: ImageProtocol,
|
||||||
|
expValue: "s4:///opt/",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "docker protocol",
|
||||||
|
input: "docker://ubuntu:20.04",
|
||||||
|
expType: ImageProtocol,
|
||||||
|
expValue: "docker://ubuntu:20.04",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range testCases {
|
||||||
|
t.Run(test.desc, func(t *testing.T) {
|
||||||
|
p := NewProtocol(test.input)
|
||||||
|
if p.Type != test.expType {
|
||||||
|
t.Errorf("mismatched type in protocol: '%v' != '%v'", p.Type, test.expType)
|
||||||
|
}
|
||||||
|
if p.Value != test.expValue {
|
||||||
|
t.Errorf("mismatched protocol value: '%s' != '%s'", p.Value, test.expValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user