Skip to content
Snippets Groups Projects
Select Git revision
  • 1f79f22e47b00c160fe6c3f2d30212160da8211d
  • main default protected
  • renovate/main-vitest-monorepo
  • next
  • fix/36615b-branch-reuse-no-cache
  • chore/punycode
  • fix/36615-branch-reuse-bug
  • renovate/main-redis-5.x
  • renovate/main-xmldoc-2.x
  • refactor/pin-new-value
  • feat/36219--git-x509-signing
  • feat/structured-logger
  • hotfix/39.264.1
  • feat/skip-dangling
  • gh-readonly-queue/next/pr-36034-7a061c4ca1024a19e2c295d773d9642625d1c2be
  • hotfix/39.238.3
  • refactor/gitlab-auto-approve
  • feat/template-strings
  • gh-readonly-queue/next/pr-35654-137d934242c784e0c45d4b957362214f0eade1d7
  • fix/32307-global-extends-merging
  • fix/32307-global-extends-repositories
  • 41.9.0
  • 41.8.0
  • 41.7.2
  • 41.7.1
  • 41.7.0
  • 41.6.4
  • 41.6.3
  • 41.6.2
  • 41.6.1
  • 41.6.0
  • 41.5.0
  • 41.4.0
  • 41.3.0
  • 41.2.0
  • 41.1.4
  • 41.1.3
  • 41.1.2
  • 41.1.1
  • 41.1.0
  • 41.0.0
41 results

markdown.spec.ts

Blame
  • controls_test.go 3.71 KiB
    // Copyright © 2017-2019 Aqua Security Software Ltd. <info@aquasec.com>
    //
    // Licensed under the Apache License, Version 2.0 (the "License");
    // you may not use this file except in compliance with the License.
    // You may obtain a copy of the License at
    //
    //     http://www.apache.org/licenses/LICENSE-2.0
    //
    // Unless required by applicable law or agreed to in writing, software
    // distributed under the License is distributed on an "AS IS" BASIS,
    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    // See the License for the specific language governing permissions and
    // limitations under the License.
    
    package check
    
    import (
    	"io/ioutil"
    	"os"
    	"path/filepath"
    	"testing"
    
    	"github.com/stretchr/testify/assert"
    	"github.com/stretchr/testify/mock"
    	"gopkg.in/yaml.v2"
    )
    
    const cfgDir = "../cfg/"
    
    type mockRunner struct {
    	mock.Mock
    }
    
    func (m *mockRunner) Run(c *Check) State {
    	args := m.Called(c)
    	return args.Get(0).(State)
    }
    
    // validate that the files we're shipping are valid YAML
    func TestYamlFiles(t *testing.T) {
    	err := filepath.Walk(cfgDir, func(path string, info os.FileInfo, err error) error {
    		if err != nil {
    			t.Fatalf("failure accessing path %q: %v\n", path, err)
    		}
    		if !info.IsDir() {
    			t.Logf("reading file: %s", path)
    			in, err := ioutil.ReadFile(path)
    			if err != nil {
    				t.Fatalf("error opening file %s: %v", path, err)
    			}
    
    			c := new(Controls)
    			err = yaml.Unmarshal(in, c)
    			if err == nil {
    				t.Logf("YAML file successfully unmarshalled: %s", path)
    			} else {
    				t.Fatalf("failed to load YAML from %s: %v", path, err)
    			}
    		}
    		return nil
    	})
    	if err != nil {
    		t.Fatalf("failure walking cfg dir: %v\n", err)
    	}
    }
    
    func TestNewControls(t *testing.T) {
    
    	t.Run("Should return error when node type is not specified", func(t *testing.T) {
    		// given