(t *testing.T)
| 824 | } |
| 825 | |
| 826 | func TestSetMetadata(t *testing.T) { |
| 827 | tests := []struct { |
| 828 | v1 string |
| 829 | metadata string |
| 830 | expectedVersion string |
| 831 | expectedMetadata string |
| 832 | expectedOriginal string |
| 833 | expectedErr error |
| 834 | }{ |
| 835 | {"1.2.3", "**", "1.2.3", "", "1.2.3", ErrInvalidMetadata}, |
| 836 | {"1.2.3", "meta", "1.2.3+meta", "meta", "1.2.3+meta", nil}, |
| 837 | {"v1.2.4", "meta", "1.2.4+meta", "meta", "v1.2.4+meta", nil}, |
| 838 | } |
| 839 | |
| 840 | for _, tc := range tests { |
| 841 | v1, err := NewVersion(tc.v1) |
| 842 | if err != nil { |
| 843 | t.Errorf("Error parsing version: %s", err) |
| 844 | } |
| 845 | |
| 846 | v2, err := v1.SetMetadata(tc.metadata) |
| 847 | if err != tc.expectedErr { |
| 848 | t.Errorf("Expected to get err=%s, but got err=%s", tc.expectedErr, err) |
| 849 | } |
| 850 | |
| 851 | a := v2.Metadata() |
| 852 | e := tc.expectedMetadata |
| 853 | if a != e { |
| 854 | t.Errorf("Expected metadata value=%q, but got %q", e, a) |
| 855 | } |
| 856 | |
| 857 | a = v2.String() |
| 858 | e = tc.expectedVersion |
| 859 | if e != a { |
| 860 | t.Errorf("Expected version string=%q, but got %q", e, a) |
| 861 | } |
| 862 | |
| 863 | a = v2.Original() |
| 864 | e = tc.expectedOriginal |
| 865 | if a != e { |
| 866 | t.Errorf("Expected version original=%q, but got %q", e, a) |
| 867 | } |
| 868 | } |
| 869 | } |
| 870 | |
| 871 | func TestOriginalVPrefix(t *testing.T) { |
| 872 | tests := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…