Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
1f703d33
Commit
1f703d33
authored
Jul 30, 2018
by
David Eads
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add methods to apimachinery to easy unit testing
parent
4bec356e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletion
+31
-1
codec.go
staging/src/k8s.io/apimachinery/pkg/api/testing/codec.go
+31
-1
No files found.
staging/src/k8s.io/apimachinery/pkg/api/testing/codec.go
View file @
1f703d33
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
testing
package
api
testing
import
(
import
(
"fmt"
"fmt"
...
@@ -84,3 +84,33 @@ func init() {
...
@@ -84,3 +84,33 @@ func init() {
}
}
}
}
}
}
// InstallOrDieFunc mirrors install functions that require success
type
InstallOrDieFunc
func
(
scheme
*
runtime
.
Scheme
)
// SchemeForInstallOrDie builds a simple test scheme and codecfactory pair for easy unit testing from higher level install methods
func
SchemeForInstallOrDie
(
installFns
...
InstallOrDieFunc
)
(
*
runtime
.
Scheme
,
runtimeserializer
.
CodecFactory
)
{
scheme
:=
runtime
.
NewScheme
()
codecFactory
:=
runtimeserializer
.
NewCodecFactory
(
scheme
)
for
_
,
installFn
:=
range
installFns
{
installFn
(
scheme
)
}
return
scheme
,
codecFactory
}
// InstallFunc mirrors install functions that can return an error
type
InstallFunc
func
(
scheme
*
runtime
.
Scheme
)
error
// SchemeForOrDie builds a simple test scheme and codecfactory pair for easy unit testing from the bare registration methods.
func
SchemeForOrDie
(
installFns
...
InstallFunc
)
(
*
runtime
.
Scheme
,
runtimeserializer
.
CodecFactory
)
{
scheme
:=
runtime
.
NewScheme
()
codecFactory
:=
runtimeserializer
.
NewCodecFactory
(
scheme
)
for
_
,
installFn
:=
range
installFns
{
if
err
:=
installFn
(
scheme
);
err
!=
nil
{
panic
(
err
)
}
}
return
scheme
,
codecFactory
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment