Debian Codegraph @

t/git-lfs-test-server-api/testdownload.go

raw symbols SCIP
1 package mainscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/
2
3 import (
4 "bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/"
5 "errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/"
6 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
7
8 "github.com/git-lfs/git-lfs/v3/toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/"
9 "github.com/git-lfs/git-lfs/v3/tqscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/"
10 )
11
12 // "download" - all present
13 func downloadAllExistscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/downloadAllExist().(manifest tqscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/.Manifestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Manifest#, oidsExist, oidsMissing []TestObjectscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/TestObject#) error {
14 retobjs, err := callBatchApiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/callBatchApi().(manifest, tqscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/.Downloadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Download., oidsExist)
15
16 if err != nil {
17 return err
18 }
19
20 if len(retobjs) != len(oidsExist) {
21 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("incorrect number of returned objects, expected %d, got %d", len(oidsExist), len(retobjs))
22 }
23
24 var errbuf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#
25 for _, o := range retobjs {
26 rel, _ := o.Relscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Rel().("download")
27 if rel == nil {
28 errbuf.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("Missing download link for %s\n", o.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid.))
29 }
30 }
31
32 if errbuf.Lenscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#Len().() > 0 {
33 return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().(errbuf.Stringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#String().())
34 }
35
36 return nil
37 }
38
39 // "download" - all missing (test includes 404 error entry)
40 func downloadAllMissingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/downloadAllMissing().(manifest tqscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/.Manifestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Manifest#, oidsExist, oidsMissing []TestObjectscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/TestObject#) error {
41 retobjs, err := callBatchApiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/callBatchApi().(manifest, tqscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/.Downloadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Download., oidsMissing)
42
43 if err != nil {
44 return err
45 }
46
47 if len(retobjs) != len(oidsMissing) {
48 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("incorrect number of returned objects, expected %d, got %d", len(oidsMissing), len(retobjs))
49 }
50
51 var errbuf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#
52 for _, o := range retobjs {
53 link, _ := o.Relscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Rel().("download")
54 if link != nil {
55 errbuf.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("Download link should not exist for %s, was %+v\n", o.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid., link))
56 }
57 if o.Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Error. == nil {
58 errbuf.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("Download should include an error for missing object %s\n", o.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid.))
59 } else if o.Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Error..Codescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/ObjectError#Code. != 404 {
60 errbuf.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("Download error code for missing object %s should be 404, got %d\n", o.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid., o.Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Error..Codescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/ObjectError#Code.))
61 }
62 }
63
64 if errbuf.Lenscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#Len().() > 0 {
65 return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().(errbuf.Stringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#String().())
66 }
67
68 return nil
69 }
70
71 // "download" - mixture
72 func downloadMixedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/downloadMixed().(manifest tqscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/.Manifestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Manifest#, oidsExist, oidsMissing []TestObjectscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/TestObject#) error {
73 existSet := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.NewStringSetWithCapacityscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewStringSetWithCapacity().(len(oidsExist))
74 for _, o := range oidsExist {
75 existSet.Addscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/StringSet#Add().(o.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/TestObject#Oid.)
76 }
77 missingSet := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.NewStringSetWithCapacityscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewStringSetWithCapacity().(len(oidsMissing))
78 for _, o := range oidsMissing {
79 missingSet.Addscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/StringSet#Add().(o.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/TestObject#Oid.)
80 }
81
82 calloids := interleaveTestDatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/interleaveTestData().(oidsExist, oidsMissing)
83 retobjs, err := callBatchApiscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/callBatchApi().(manifest, tqscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/.Downloadscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Download., calloids)
84
85 if err != nil {
86 return err
87 }
88
89 count := len(oidsExist) + len(oidsMissing)
90 if len(retobjs) != count {
91 return fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("incorrect number of returned objects, expected %d, got %d", count, len(retobjs))
92 }
93
94 var errbuf bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#
95 for _, o := range retobjs {
96 link, _ := o.Relscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Rel().("download")
97 if missingSet.Containsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/StringSet#Contains().(o.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid.) {
98 if link != nil {
99 errbuf.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("Download link should not exist for %s, was %+v\n", o.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid., link))
100 }
101 if o.Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Error. == nil {
102 errbuf.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("Download should include an error for missing object %s", o.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid.))
103 } else if o.Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Error..Codescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/ObjectError#Code. != 404 {
104 errbuf.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("Download error code for missing object %s should be 404, got %d\n", o.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid., o.Errorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Error..Codescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/ObjectError#Code.))
105 }
106 }
107 if existSet.Containsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/StringSet#Contains().(o.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid.) && link == nil {
108 errbuf.WriteStringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#WriteString().(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("Missing download link for %s\n", o.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tq`/Transfer#Oid.))
109 }
110
111 }
112
113 if errbuf.Lenscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#Len().() > 0 {
114 return errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 errors/New().(errbuf.Stringscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#String().())
115 }
116
117 return nil
118
119 }
120
121 func initscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/init().() {
122 addTestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/addTest().("Test download: all existing", downloadAllExistscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/downloadAllExist().)
123 addTestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/addTest().("Test download: all missing", downloadAllMissingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/downloadAllMissing().)
124 addTestscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/addTest().("Test download: mixed", downloadMixedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/t/git-lfs-test-server-api`/downloadMixed().)
125 }