go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/llx/rawdata_json_test.go (about)

     1  // Copyright (c) Mondoo, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package llx
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func TestRawDataJson_removeUnderscoreKeys(t *testing.T) {
    13  	tests := map[string]struct {
    14  		input []string
    15  		want  []string
    16  	}{
    17  		"no underscores": {
    18  			input: []string{"this", "that"},
    19  			want:  []string{"this", "that"},
    20  		},
    21  		"trailing underscore": {
    22  			input: []string{"this", "that", "_"},
    23  			want:  []string{"this", "that"},
    24  		},
    25  		"leading underscore": {
    26  			input: []string{"_", "this", "that"},
    27  			want:  []string{"this", "that"},
    28  		},
    29  		"alternating underscores": {
    30  			input: []string{"_", "this", "_", "that", "_"},
    31  			want:  []string{"this", "that"},
    32  		},
    33  		"all underscores": {
    34  			input: []string{"_", "_", "_"},
    35  			want:  []string{},
    36  		},
    37  	}
    38  
    39  	for name, tc := range tests {
    40  		t.Run(name, func(t *testing.T) {
    41  			got := removeUnderscoreKeys(tc.input)
    42  			assert.Equal(t, tc.want, got)
    43  		})
    44  	}
    45  }