Last active
November 16, 2023 10:10
-
-
Save yulintan/8094b27742f6789267f147405734cb94 to your computer and use it in GitHub Desktop.
It provides a way for testing private function in Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package service | |
var CalculateSum = calculateSum |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package service | |
func calculateSum(a, b int) int { | |
return a + b | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package service_test | |
import ( | |
. "github.com/onsi/ginkgo" | |
. "github.com/onsi/gomega" | |
service "github.com/yulintan/test-private-function" | |
) | |
var _ = Describe("myService", func() { | |
It("returns the sum", func() { | |
r := service.CalculateSum(1, 2) | |
Expect(r).To(Equal(3)) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment