Skip to content

Commit

Permalink
store: even if a local_resource has no build command, it can still be…
Browse files Browse the repository at this point in the history
… pending (#4161)
  • Loading branch information
nicks committed Feb 4, 2021
1 parent 164b086 commit 83f12eb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/store/manifest_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@ func (t ManifestTarget) Status() model.TargetStatus {

func (mt *ManifestTarget) UpdateStatus() model.UpdateStatus {
m := mt.Manifest
us := mt.State.UpdateStatus(m.TriggerMode)

if us == model.UpdateStatusPending {
// A resource with no update command can still be in pending mode.
return us
}

if m.IsLocal() && m.LocalTarget().UpdateCmd.Empty() {
return model.UpdateStatusNotApplicable
}

return mt.State.UpdateStatus(m.TriggerMode)
return us
}

var _ model.Target = &ManifestTarget{}
Expand Down
15 changes: 15 additions & 0 deletions internal/store/manifest_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"encoding/base64"
"fmt"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/tilt-dev/tilt/pkg/model"
Expand All @@ -31,3 +33,16 @@ func TestManifestTarget_FacetsSecretsScrubbed(t *testing.T) {

require.Equal(t, expected, actual)
}

func TestLocalTargetUpdateStatus(t *testing.T) {
m := model.Manifest{Name: "serve-cmd"}.WithDeployTarget(
model.NewLocalTarget("serve-cmd", model.Cmd{}, model.ToHostCmd("busybox httpd"), nil))
mt := NewManifestTarget(m)
assert.Equal(t, model.UpdateStatusPending, mt.UpdateStatus())

mt.State.AddCompletedBuild(model.BuildRecord{StartTime: time.Now(), FinishTime: time.Now()})
assert.Equal(t, model.UpdateStatusNotApplicable, mt.UpdateStatus())

mt.State.TriggerReason = model.BuildReasonFlagTriggerWeb
assert.Equal(t, model.UpdateStatusPending, mt.UpdateStatus())
}

0 comments on commit 83f12eb

Please sign in to comment.