MCPcopy Index your code
hub / github.com/devspace-sh/devspace / TestInitialSync

Function TestInitialSync

pkg/devspace/sync/sync_test.go:53–154  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51}
52
53func TestInitialSync(t *testing.T) {
54 for _, initialSync := range []latest.InitialSyncStrategy{latest.InitialSyncStrategyPreferLocal, latest.InitialSyncStrategyMirrorLocal} {
55 t.Log("InitialSyncStrategy: " + initialSync)
56 remote, local, outside := initTestDirs(t)
57 defer os.RemoveAll(remote)
58 defer os.RemoveAll(local)
59 defer os.RemoveAll(outside)
60
61 filesToCheck, foldersToCheck := makeBasicTestCases()
62 if initialSync == latest.InitialSyncStrategyMirrorLocal {
63 filesToCheck = disableDownload(filesToCheck)
64 foldersToCheck = disableDownload(foldersToCheck)
65 }
66
67 // Start the client
68 syncClient, err := createTestSyncClient(local, append(filesToCheck, foldersToCheck...))
69 if err != nil {
70 t.Fatal(err)
71 }
72 defer syncClient.Stop(nil)
73 syncClient.Options.InitialSync = initialSync
74
75 // Set bandwidth limits
76 syncClient.Options.DownstreamLimit = 1024
77 syncClient.Options.UpstreamLimit = 512
78
79 // Start the downstream server
80 downClientReader, downClientWriter, _ := os.Pipe()
81 downServerReader, downServerWriter, _ := os.Pipe()
82 defer downClientReader.Close()
83 defer downClientWriter.Close()
84 defer downServerReader.Close()
85 defer downServerWriter.Close()
86
87 t.Logf("Exclude paths: %#+v", syncClient.Options.ExcludePaths)
88 t.Logf("Upload Exclude paths: %#+v", syncClient.Options.UploadExcludePaths)
89 t.Logf("Download Exclude paths: %#+v", syncClient.Options.DownloadExcludePaths)
90
91 // Build exclude paths
92 excludePaths := []string{}
93 excludePaths = append(excludePaths, syncClient.Options.ExcludePaths...)
94 excludePaths = append(excludePaths, syncClient.Options.DownloadExcludePaths...)
95
96 go func() {
97 err := server.StartDownstreamServer(downServerReader, downClientWriter, &server.DownstreamOptions{
98 RemotePath: remote,
99 ExcludePaths: excludePaths,
100 ExitOnClose: false,
101 })
102 if err != nil {
103 panic(err)
104 }
105 }()
106
107 // Start downstream client
108 err = syncClient.InitDownstream(downClientReader, downServerWriter)
109 if err != nil {
110 t.Fatal(err)

Callers

nothing calls this directly

Calls 15

StartDownstreamServerFunction · 0.92
StartUpstreamServerFunction · 0.92
initTestDirsFunction · 0.85
makeBasicTestCasesFunction · 0.85
disableDownloadFunction · 0.85
createTestSyncClientFunction · 0.85
checkFilesAndFoldersFunction · 0.85
InitDownstreamMethod · 0.80
InitUpstreamMethod · 0.80
startUpstreamMethod · 0.80
initialSyncMethod · 0.80

Tested by

no test coverage detected