github.com/google/cadvisor@v0.49.1/container/docker/utils/docker_test.go (about)

     1  // Copyright 2022 Google Inc. All Rights Reserved.
     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 utils
    16  
    17  import "testing"
    18  
    19  func TestIsContainerName(t *testing.T) {
    20  	tests := []struct {
    21  		name     string
    22  		expected bool
    23  	}{
    24  		{
    25  			name:     "/system.slice/var-lib-docker-overlay-9f086b233ab7c786bf8b40b164680b658a8f00e94323868e288d6ce20bc92193-merged.mount",
    26  			expected: false,
    27  		},
    28  		{
    29  			name:     "/system.slice/docker-72e5a5ff5eef3c4222a6551b992b9360a99122f77d2229783f0ee0946dfd800e.scope",
    30  			expected: true,
    31  		},
    32  	}
    33  	for _, test := range tests {
    34  		if actual := IsContainerName(test.name); actual != test.expected {
    35  			t.Errorf("%s: expected: %v, actual: %v", test.name, test.expected, actual)
    36  		}
    37  	}
    38  }