-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprovider_test.go
More file actions
52 lines (42 loc) · 1.38 KB
/
provider_test.go
File metadata and controls
52 lines (42 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) Spice AI, Inc. 2025, 2026
// SPDX-License-Identifier: MPL-2.0
package provider
import (
"os"
"testing"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
)
// testAccProtoV6ProviderFactories are used to instantiate a provider during
// acceptance testing. The factory function will be invoked for every Terraform
// CLI command executed to create a provider server to which the CLI can
// reattach.
var _ = map[string]func() (tfprotov6.ProviderServer, error){
"spiceai": providerserver.NewProtocol6WithError(New("test")()),
}
func init() {
// Reference testAccPreCheck to avoid unused function error.
_ = testAccPreCheck
}
func testAccPreCheck(t *testing.T) {
// Check that required environment variables are set for acceptance tests
if v := os.Getenv("SPICEAI_CLIENT_ID"); v == "" {
t.Fatal("SPICEAI_CLIENT_ID must be set for acceptance tests")
}
if v := os.Getenv("SPICEAI_CLIENT_SECRET"); v == "" {
t.Fatal("SPICEAI_CLIENT_SECRET must be set for acceptance tests")
}
}
func TestProviderNew(t *testing.T) {
p := New("test")()
if p == nil {
t.Fatal("expected provider to be non-nil")
}
sp, ok := p.(*SpiceAIProvider)
if !ok {
t.Fatalf("expected provider to be *SpiceAIProvider, got %T", p)
}
if sp.version != "test" {
t.Errorf("expected version to be 'test', got '%s'", sp.version)
}
}