Codebase list golang-github-git-lfs-gitobj / 618415e0-6c48-48cd-8285-cca3847f471c/upstream object_type_test.go
618415e0-6c48-48cd-8285-cca3847f471c/upstream

Tree @618415e0-6c48-48cd-8285-cca3847f471c/upstream (Download .tar.gz)

object_type_test.go @618415e0-6c48-48cd-8285-cca3847f471c/upstreamraw · history · blame

package gitobj

import (
	"math"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestObjectTypeFromString(t *testing.T) {
	for str, typ := range map[string]ObjectType{
		"blob":           BlobObjectType,
		"tree":           TreeObjectType,
		"commit":         CommitObjectType,
		"tag":            TagObjectType,
		"something else": UnknownObjectType,
	} {
		t.Run(str, func(t *testing.T) {
			assert.Equal(t, typ, ObjectTypeFromString(str))
		})
	}
}

func TestObjectTypeToString(t *testing.T) {
	for typ, str := range map[ObjectType]string{
		BlobObjectType:            "blob",
		TreeObjectType:            "tree",
		CommitObjectType:          "commit",
		TagObjectType:             "tag",
		UnknownObjectType:         "unknown",
		ObjectType(math.MaxUint8): "<unknown>",
	} {
		t.Run(str, func(t *testing.T) {
			assert.Equal(t, str, typ.String())
		})
	}
}