inferere_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2023 EMQ Technologies Co., Ltd.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package schema
  15. import (
  16. "errors"
  17. "testing"
  18. "github.com/stretchr/testify/assert"
  19. )
  20. func TestInferFromSchemaFileError(t *testing.T) {
  21. tests := []struct {
  22. name string
  23. schemaType string
  24. schemaId string
  25. err error
  26. }{
  27. {
  28. name: "test weak schema type",
  29. schemaType: "can",
  30. schemaId: "aa",
  31. err: nil,
  32. }, {
  33. name: "test wrong schema id",
  34. schemaType: "protobuf",
  35. schemaId: "aa",
  36. err: errors.New("invalid schemaId: aa"),
  37. },
  38. }
  39. for _, tt := range tests {
  40. t.Run(tt.name, func(t *testing.T) {
  41. _, err := InferFromSchemaFile(tt.schemaType, tt.schemaId)
  42. assert.Equal(t, tt.err, err)
  43. })
  44. }
  45. }