github.com/ystia/yorc/v4@v4.3.0/storage/internal/consul/consul_test.go (about)

     1  // Copyright 2019 Bull S.A.S. Atos Technologies - Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois, France.
     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  
    15  package consul
    16  
    17  import (
    18  	"github.com/hashicorp/consul/sdk/testutil"
    19  	"os"
    20  	"testing"
    21  
    22  	"github.com/ystia/yorc/v4/storage/encoding"
    23  	"github.com/ystia/yorc/v4/storage/store"
    24  )
    25  
    26  // The aim of this function is to run all package tests with consul server dependency with only one consul server start
    27  func TestRunConsulStoragePackageTests(t *testing.T) {
    28  	cfg := store.SetupTestConfig(t)
    29  	srv, _ := store.NewTestConsulInstance(t, &cfg)
    30  	defer func() {
    31  		srv.Stop()
    32  		os.RemoveAll(cfg.WorkingDirectory)
    33  	}()
    34  
    35  	t.Run("groupConsulStore", func(t *testing.T) {
    36  		t.Run("testConsulTypes", func(t *testing.T) {
    37  			testTypes(t, srv)
    38  		})
    39  		t.Run("testConsulStore", func(t *testing.T) {
    40  			testStore(t, srv)
    41  		})
    42  	})
    43  }
    44  
    45  func testStore(t *testing.T, srv1 *testutil.TestServer) {
    46  	csStore := &consulStore{encoding.JSON}
    47  	store.CommonStoreTest(t, csStore)
    48  }
    49  
    50  func testTypes(t *testing.T, srv1 *testutil.TestServer) {
    51  	csStore := &consulStore{encoding.JSON}
    52  	store.CommonStoreTestAllTypes(t, csStore)
    53  }