mirror of
				https://github.com/onepanelio/onepanel.git
				synced 2025-11-01 01:02:32 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			34 lines
		
	
	
		
			633 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			633 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package v1
 | |
| 
 | |
| import (
 | |
| 	"strconv"
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/stretchr/testify/assert"
 | |
| 	corev1 "k8s.io/api/core/v1"
 | |
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | |
| )
 | |
| 
 | |
| func testCreateNamespace(c *Client) {
 | |
| 	for i := 0; i < 5; i++ {
 | |
| 		c.CoreV1().Namespaces().Create(&corev1.Namespace{
 | |
| 			ObjectMeta: metav1.ObjectMeta{
 | |
| 				Name: "namespace-" + strconv.Itoa(i),
 | |
| 				Labels: map[string]string{
 | |
| 					"onepanel.io/enabled": "true",
 | |
| 				},
 | |
| 			},
 | |
| 		})
 | |
| 	}
 | |
| }
 | |
| func TestListNamespace(t *testing.T) {
 | |
| 	c := NewTestClient()
 | |
| 
 | |
| 	testCreateNamespace(c)
 | |
| 
 | |
| 	n, err := c.ListNamespaces()
 | |
| 	assert.Nil(t, err)
 | |
| 	assert.NotEmpty(t, n)
 | |
| 	assert.Equal(t, len(n), 5)
 | |
| }
 | 
