@@ -354,6 +354,49 @@ var _ = Describe("Function Controller", func() {
354354 Expect (readyCond .Status ).To (Equal (metav1 .ConditionFalse ))
355355 },
356356 }),
357+ Entry ("should record history event when middleware is redeployed" , reconcileTestCase {
358+ spec : defaultSpec ,
359+ configureMocks : func (funcMock * funccli.MockManager , gitMock * git.MockManager ) {
360+ funcMock .EXPECT ().Describe (mock .Anything , functionName , resourceNamespace ).Return (functions.Instance {
361+ Middleware : functions.Middleware {
362+ Version : "v1.0.0" ,
363+ },
364+ }, nil )
365+ funcMock .EXPECT ().GetLatestMiddlewareVersion (mock .Anything , mock .Anything , mock .Anything ).Return ("v2.0.0" , nil )
366+ funcMock .EXPECT ().GetMiddlewareVersion (mock .Anything , functionName , resourceNamespace ).Return ("v1.0.0" , nil )
367+ funcMock .EXPECT ().Deploy (mock .Anything , mock .Anything , resourceNamespace , funccli.DeployOptions {}).Return (nil )
368+
369+ gitMock .EXPECT ().CloneRepository (mock .Anything , "https://github.com/foo/bar" , "" , "my-branch" , mock .Anything ).Return (createTmpGitRepo (functions.Function {Name : "func-go" }), nil )
370+ },
371+ statusChecks : func (status * functionsdevv1alpha1.FunctionStatus ) {
372+ messages := make ([]string , len (status .History ))
373+ for i , entry := range status .History {
374+ messages [i ] = entry .Message
375+ }
376+ Expect (messages ).To (ContainElement (`Middleware updated from "v1.0.0" to "v2.0.0"` ))
377+ },
378+ }),
379+ Entry ("should not record middleware history event when middleware is already up to date" , reconcileTestCase {
380+ spec : defaultSpec ,
381+ configureMocks : func (funcMock * funccli.MockManager , gitMock * git.MockManager ) {
382+ funcMock .EXPECT ().Describe (mock .Anything , functionName , resourceNamespace ).Return (functions.Instance {
383+ Middleware : functions.Middleware {
384+ Version : "v1.0.0" ,
385+ },
386+ }, nil )
387+ funcMock .EXPECT ().GetLatestMiddlewareVersion (mock .Anything , mock .Anything , mock .Anything ).Return ("v1.0.0" , nil )
388+ funcMock .EXPECT ().GetMiddlewareVersion (mock .Anything , functionName , resourceNamespace ).Return ("v1.0.0" , nil )
389+
390+ gitMock .EXPECT ().CloneRepository (mock .Anything , "https://github.com/foo/bar" , "" , "my-branch" , mock .Anything ).Return (createTmpGitRepo (functions.Function {Name : "func-go" }), nil )
391+ },
392+ statusChecks : func (status * functionsdevv1alpha1.FunctionStatus ) {
393+ messages := make ([]string , len (status .History ))
394+ for i , entry := range status .History {
395+ messages [i ] = entry .Message
396+ }
397+ Expect (messages ).ToNot (ContainElement (ContainSubstring ("Middleware updated" )))
398+ },
399+ }),
357400 Entry ("should set ServiceReady condition to false with unknown reason when ready status is empty" , reconcileTestCase {
358401 spec : defaultSpec ,
359402 configureMocks : func (funcMock * funccli.MockManager , gitMock * git.MockManager ) {
0 commit comments