func (s *Cache) Changed() bool {
	if s.updatedCount > 0 || s.insertedCount > 0 {
		return true
	}
	for test, cachedFiles := range s.cached {
		if _, ok := s.current[test]; !ok {
			return true
		}
		for idx := range cachedFiles {
			if _, ok := s.current[test][idx]; !ok {
				return true
			}
		}
	}
	return false
}
Changed check if content have changed according to all Compare called
package snapshot
import (
	"io/ioutil"
	"os"
	"github.com/lrills/helm-unittest/unittest/common"
	yaml "gopkg.in/yaml.v2"
)
type CompareResult struct {
	Passed         bool
	Test           string
	Index          uint
	NewSnapshot    string
	CachedSnapshot string
}
type Cache struct {
	Filepath      string
	Existed       bool
	IsUpdating    bool
	cached        map[string]map[uint]string
	current       map[string]map[uint]string
	updatedCount  uint
	insertedCount uint
	currentCount  uint
}
func (s *Cache) RestoreFromFile() error {
	content, err := ioutil.ReadFile(s.Filepath)
	if err != nil {
		if os.IsNotExist(err) {
			return nil
		}
		return err
	}
	if err := yaml.Unmarshal(content, &s.cached); err != nil {
		return err
	}
	s.Existed = true
	return nil
}
func (s *Cache) getCached(test string, idx uint) (string, bool) {
	if cachedByTest, ok := s.cached[test]; ok {
		if cachedOfAssertion, ok := cachedByTest[idx]; ok {
			return cachedOfAssertion, true
		}
	}
	return "", false
}
func (s *Cache) Compare(test string, idx uint, content interface{}) *CompareResult {
	s.currentCount++
	cached, exsisted := s.getCached(test, idx)
	if !exsisted {
		s.insertedCount++
	}
	match := true
	newSnapshot := common.TrustedMarshalYAML(content)
	if exsisted && newSnapshot != cached {
		match = false
		s.updatedCount++
	}
	var snapshotToSave string
	if s.IsUpdating || !exsisted {
		snapshotToSave = newSnapshot
	} else {
		snapshotToSave = cached
	}
	s.setNewSnapshot(test, idx, snapshotToSave)
	return &CompareResult{
		Passed:         s.IsUpdating || match,
		Test:           test,
		Index:          idx,
		CachedSnapshot: cached,
		NewSnapshot:    newSnapshot,
	}
}
func (s *Cache) setNewSnapshot(test string, idx uint, snapshot string) {
	if s.current == nil {
		s.current = make(map[string]map[uint]string)
	}
	if newCacheOfTest, ok := s.current[test]; ok {
		newCacheOfTest[idx] = snapshot
	} else {
		s.current[test] = map[uint]string{idx: snapshot}
	}
}