oid_test.go 821 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package lfsutil
  5. import (
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestValidOID(t *testing.T) {
  10. tests := []struct {
  11. name string
  12. oid OID
  13. expVal bool
  14. }{
  15. {
  16. name: "malformed",
  17. oid: OID("7c222fb2927d828af22f592134e8932480637c0d"),
  18. },
  19. {
  20. name: "not all lower cased",
  21. oid: OID("EF797c8118f02dfb649607dd5d3f8c7623048c9c063d532cc95c5ed7a898a64f"),
  22. },
  23. {
  24. name: "valid",
  25. oid: OID("ef797c8118f02dfb649607dd5d3f8c7623048c9c063d532cc95c5ed7a898a64f"),
  26. expVal: true,
  27. },
  28. }
  29. for _, test := range tests {
  30. t.Run(test.name, func(t *testing.T) {
  31. assert.Equal(t, test.expVal, ValidOID(test.oid))
  32. })
  33. }
  34. }