Imported Upstream version 2.5.0
[scm/test.git] / vendor / github.com / git-lfs / gitobj / object_type_test.go
1 package gitobj
2
3 import (
4         "math"
5         "testing"
6
7         "github.com/stretchr/testify/assert"
8 )
9
10 func TestObjectTypeFromString(t *testing.T) {
11         for str, typ := range map[string]ObjectType{
12                 "blob":           BlobObjectType,
13                 "tree":           TreeObjectType,
14                 "commit":         CommitObjectType,
15                 "tag":            TagObjectType,
16                 "something else": UnknownObjectType,
17         } {
18                 t.Run(str, func(t *testing.T) {
19                         assert.Equal(t, typ, ObjectTypeFromString(str))
20                 })
21         }
22 }
23
24 func TestObjectTypeToString(t *testing.T) {
25         for typ, str := range map[ObjectType]string{
26                 BlobObjectType:            "blob",
27                 TreeObjectType:            "tree",
28                 CommitObjectType:          "commit",
29                 TagObjectType:             "tag",
30                 UnknownObjectType:         "unknown",
31                 ObjectType(math.MaxUint8): "<unknown>",
32         } {
33                 t.Run(str, func(t *testing.T) {
34                         assert.Equal(t, str, typ.String())
35                 })
36         }
37 }