github.com/nats-io/nsc/v2@v2.8.7-0.20240307184528-efd7023c6896/cmd/importcollector_test.go (about)

     1  /*
     2   * Copyright 2018-2019 The NATS Authors
     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   */
    15  
    16  package cmd
    17  
    18  import (
    19  	"testing"
    20  
    21  	"github.com/nats-io/jwt/v2"
    22  	"github.com/stretchr/testify/require"
    23  )
    24  
    25  func Test_ImportCollectorBasics(t *testing.T) {
    26  	ts := NewTestStore(t, "O")
    27  	defer ts.Done(t)
    28  	ts.AddAccount(t, "A")
    29  	ts.AddAccount(t, "A2")
    30  	ts.AddExport(t, "A2", jwt.Service, "foo", 0, true)
    31  	ts.AddExport(t, "A2", jwt.Stream, "bar", 0, false)
    32  	ts.AddAccount(t, "A3")
    33  
    34  	exports, err := GetAllExports()
    35  	require.NoError(t, err)
    36  
    37  	require.Len(t, exports, 1)
    38  	ex := exports[0]
    39  	require.Equal(t, "O", ex.OperatorName)
    40  	require.Equal(t, "A2", ex.Name)
    41  	require.Len(t, ex.Exports, 2)
    42  }