github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/pkg/graphdb/sort_test.go (about)

     1  package graphdb
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestSort(t *testing.T) {
     8  	paths := []string{
     9  		"/",
    10  		"/myreallylongname",
    11  		"/app/db",
    12  	}
    13  
    14  	sortByDepth(paths)
    15  
    16  	if len(paths) != 3 {
    17  		t.Fatalf("Expected 3 parts got %d", len(paths))
    18  	}
    19  
    20  	if paths[0] != "/app/db" {
    21  		t.Fatalf("Expected /app/db got %s", paths[0])
    22  	}
    23  	if paths[1] != "/myreallylongname" {
    24  		t.Fatalf("Expected /myreallylongname got %s", paths[1])
    25  	}
    26  	if paths[2] != "/" {
    27  		t.Fatalf("Expected / got %s", paths[2])
    28  	}
    29  }