// Copyright (C) 2019 rameshvk. All rights reserved.
// Use of this source code is governed by a MIT-style license
// that can be found in the LICENSE file.

package riched_test

import (
	"testing"

	"github.com/dotchain/dot/changes"
	"github.com/dotchain/dot/changes/types"
	"github.com/dotchain/dot/x/rich/riched"
)

func TestNoAttribute(t *testing.T) {
	n := riched.NoAttribute("something")
	if n.Name() != "something" {
		t.Error("Unexpected name", string(n))
	}

	if x := n.Apply(nil, nil); x != n {
		t.Error("Unexpected nil apply", x)
	}

	replace := changes.Replace{Before: n, After: types.S16("ok")}
	if x := n.Apply(nil, replace); x != replace.After {
		t.Error("Unexpected replace result", x)
	}

	if x := n.Apply(nil, changes.ChangeSet{replace}); x != replace.After {
		t.Error("Unexpected replace result", x)
	}
}

Related articles

dot benchmark_test

// Copyright (C) 2018 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package dot_test import ( "testing" "github.com/dotchain/dot/changes" "github.com/dotchain/

dot config

// Copyright (C) 2018 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package sync import ( "time" "github.com/dotchain/dot/log" "github.com/dotchain/dot/ops" )

dot empty

// Copyright (C) 2018 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package changes // Nil represents an empty value. It can be used with Replace or // Splice to i

dot caret_test

// Copyright (C) 2018 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package refs_test import ( "reflect" "testing" "github.com/dotchain/dot/changes" "github.c

dot nw_test

// Copyright (C) 2018 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package nw_test import ( "bytes" "context" "errors" "net/http" "net/http/httptest" "testi

dot image

// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package data import ( "github.com/dotchain/dot/changes" "github.com/dotchain/dot/changes/type

dot rank_test

// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package crdt_test import ( "testing" "github.com/dotchain/dot/changes/crdt" ) func TestNewR

dot ord_test

// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package crdt_test import ( "testing" "github.com/dotchain/dot/changes/crdt" ) func TestIntN

dot generated2

// Generated. DO NOT EDIT. package mystruct import ( "github.com/dotchain/dot/changes" "github.com/dotchain/dot/changes/types" "github.com/dotchain/dot/streams" ) func (my *myStructp) get(key interface{}) changes.Value { switch key { case "b":

dot todo

// Code generated by github.com/tvastar/test/cmd/testmd/testmd.go. DO NOT EDIT. package example import ( "net/http" "sync" "time" "github.com/dotchain/dot" "github.com/dotchain/dot/ops/nw" ) func Server() { // import net/http // import github.