File: constraint_test.go

package info (click to toggle)
golang-github-mcuadros-go-version 1.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 176 kB
  • sloc: makefile: 2
file content (50 lines) | stat: -rw-r--r-- 1,043 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package version

import (
	"testing"
)

func TestGetOperator(t *testing.T) {
	constraint := NewConstrain("=", "1.0.0")
	out := "="

	if x := constraint.GetOperator(); x != "=" {
		t.Errorf("FAIL: GetOperator() = {%s}: want {%s}", x, out)
	}
}

func TestGetVersion(t *testing.T) {
	constraint := NewConstrain("=", "1.0.0")
	out := "1.0.0"

	if x := constraint.GetVersion(); x != "1.0.0" {
		t.Errorf("FAIL: GetVersion() = {%s}: want {%s}", x, out)
	}
}

func TestString(t *testing.T) {
	constraint := NewConstrain("=", "1.0.0")
	out := "= 1.0.0"

	if x := constraint.String(); x != out {
		t.Errorf("FAIL: String() = {%s}: want {%s}", x, out)
	}
}

func TestMatchSuccess(t *testing.T) {
	constraint := NewConstrain("=", "1.0.0")
	out := true

	if x := constraint.Match("1.0"); x != out {
		t.Errorf("FAIL: Match() = {%v}: want {%v}", x, out)
	}
}

func TestMatchFail(t *testing.T) {
	constraint := NewConstrain("=", "1.0.0")
	out := false

	if x := constraint.Match("2.0"); x != out {
		t.Errorf("FAIL: Match() = {%v}: want {%v}", x, out)
	}
}