github.com/google/cadvisor@v0.49.1/container/crio/factory_test.go (about) 1 // Copyright 2017 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 crio 16 17 import ( 18 "testing" 19 20 "github.com/stretchr/testify/assert" 21 ) 22 23 type canHandleAndAccept struct { 24 canHandle bool 25 canAccept bool 26 } 27 28 func TestCanHandleAndAccept(t *testing.T) { 29 as := assert.New(t) 30 f := &crioFactory{ 31 client: nil, 32 cgroupSubsystems: nil, 33 fsInfo: nil, 34 machineInfoFactory: nil, 35 storageDriver: "", 36 storageDir: "", 37 includedMetrics: nil, 38 } 39 for k, v := range map[string]canHandleAndAccept{ 40 "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/crio-81e5c2990803c383229c9680ce964738d5e566d97f5bd436ac34808d2ec75d5f": {true, false}, 41 "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/crio-81e5c2990803c383229c9680ce964738d5e566d97f5bd436ac34808d2ec75d5f.scope": {true, true}, 42 "/system.slice/system-systemd\\\\x2dcoredump.slice": {true, false}, 43 "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/crio-81e5c2990803c383229c9680ce964738d5e566d97f5bd436ac34808d2ec75d5f.mount": {false, false}, 44 "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/crio-conmon-81e5c2990803c383229c9680ce964738d5e566d97f5bd436ac34808d2ec75d5f": {false, false}, 45 "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/no-crio-conmon-81e5c2990803c383229c9680ce964738d5e566d97f5bd436ac34808d2ec75d5f": {false, false}, 46 "/kubepods/pod068e8fa0-9213-11e7-a01f-507b9d4141fa/crio-990803c383229c9680ce964738d5e566d97f5bd436ac34808d2ec75": {false, false}, 47 } { 48 b1, b2, err := f.CanHandleAndAccept(k) 49 as.Nil(err) 50 as.Equal(b1, v.canHandle) 51 as.Equal(b2, v.canAccept) 52 } 53 }