@@ -2,15 +2,15 @@ package framework
22
33import (
44 "fmt"
5- "io/ioutil"
6- "os"
7- "strings"
8- "time"
9-
5+ "github.com/go-resty/resty/v2"
106 "github.com/loft-sh/devspace/e2e/kube"
117 "github.com/onsi/gomega"
128 "github.com/pkg/errors"
9+ "io/ioutil"
1310 "k8s.io/apimachinery/pkg/util/wait"
11+ "os"
12+ "strings"
13+ "time"
1414)
1515
1616// ExpectEqual expects the specified two are the same, otherwise an exception raises
@@ -28,7 +28,7 @@ func ExpectError(err error, explain ...interface{}) {
2828 gomega .ExpectWithOffset (1 , err ).To (gomega .HaveOccurred (), explain ... )
2929}
3030
31- // ExpectMatchError expects an error happens and has a message matching the given string, otherwise an exception raises
31+ // ExpectErrorMatch ExpectMatchError expects an error happens and has a message matching the given string, otherwise an exception raises
3232func ExpectErrorMatch (err error , msg string , explain ... interface {}) {
3333 gomega .ExpectWithOffset (1 , err ).To (gomega .HaveOccurred (), explain ... )
3434 gomega .ExpectWithOffset (1 , err , explain ... ).To (gomega .MatchError (msg ), explain ... )
@@ -75,6 +75,30 @@ func ExpectRemoteFileContents(imageSelector string, namespace string, filePath s
7575 ExpectNoErrorWithOffset (1 , err )
7676}
7777
78+ func ExpectLocalCurlContents (urlString string , contents string ) {
79+ client := resty .New ()
80+ err := wait .PollImmediate (time .Second , time .Minute * 2 , func () (done bool , err error ) {
81+ resp , _ := client .R ().
82+ EnableTrace ().
83+ Get (urlString )
84+ return strings .TrimSpace (string (resp .Body ())) == strings .TrimSpace (contents ), nil
85+ })
86+ ExpectNoErrorWithOffset (1 , err )
87+ }
88+
89+ func ExpectRemoteCurlContents (imageSelector string , namespace string , urlString string , contents string ) {
90+ kubeClient , err := kube .NewKubeHelper ()
91+ ExpectNoErrorWithOffset (1 , err )
92+ err = wait .PollImmediate (time .Second , time .Minute * 2 , func () (done bool , err error ) {
93+ out , err := kubeClient .ExecByImageSelector (imageSelector , namespace , []string {"curl" , urlString })
94+ if err != nil {
95+ return false , nil
96+ }
97+ return strings .TrimSpace (out ) == strings .TrimSpace (contents ), nil
98+ })
99+ ExpectNoErrorWithOffset (1 , err )
100+ }
101+
78102func ExpectRemoteFileNotFound (imageSelector string , namespace string , filePath string ) {
79103 kubeClient , err := kube .NewKubeHelper ()
80104 ExpectNoErrorWithOffset (1 , err )
0 commit comments